'LINQ : how do I simplify this query?
How do I simplify this query?
var cookieList = _httpContextAccessor.HttpContext.Request.Cookies.ToList()
.Select(cookie => new { cookie.Key, cookie.Value })
.AsEnumerable()
.Select(cookie => $"{cookie.Key}={cookie.Value}")
.ToList()
Solution 1:[1]
var cookieList = _httpContextAccessor.HttpContext.Request.Cookies // assumed IEnumerable otherwise .ToList is ok
.Select(cookie => $"{cookie.Key}={cookie.Value}")
.ToList()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | snr |
