Под ASP net core 3.1.
У меня есть Entity Framework
query
, который создает List<Type>
следующим образом:
var opts = _context.Opt_I30
.Where(x => x.UnderlyingSymbol == "SPX" && x.QuoteDatetime < dt)
.Select(x => new { x.UnderlyingSymbol, x.QuoteDatetime, x.Expiration, x.Strike,
x.OptionType, x.Bid, x.Ask, x.UnderlyingBid, x.UnderlyingAsk, x.IV })
.OrderBy(x => x.QuoteDatetime)
.ThenBy(x => x.Expiration)
.ThenBy(x => x.OptionType)
.ThenBy(x => x.Strike)
.ToList()
;
В Select
как добавить уникальный идентификатор в строки ? Это не похоже на работу:
long id = 0;
new { id++, x.UnderlyingSymbol, x.QuoteDatetime, x.Expiration, x.Strike,
x.OptionType, x.Bid, x.Ask, x.UnderlyingBid, x.UnderlyingAsk, x.IV })
РЕДАКТИРОВАТЬ 1
Если я попытаюсь изменить select
на это:
Select((x, index) => new { index, x.UnderlyingSymbol, x.QuoteDatetime, x.Expiration, x.Strike,
x.OptionType, x.Bid, x.Ask, x.UnderlyingBid, x.UnderlyingAsk, x.IV })
Я получаю исключение:
An unhandled exception occurred while processing the request.
NotSupportedException: Could not parse expression 'value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[OptionsAPI.Entities.Option]).Where(x => ((x.UnderlyingSymbol == "SPX") AndAlso (x.QuoteDatetime < __dt_0))).Select((x, index) => new <>f__AnonymousType0`11(index = index, UnderlyingSymbol = x.UnderlyingSymbol, QuoteDatetime = x.QuoteDatetime, Expiration = x.Expiration, Strike = x.Strike, OptionType = x.OptionType, Bid = x.Bid, Ask = x.Ask, UnderlyingBid = x.UnderlyingBid, UnderlyingAsk = x.UnderlyingAsk, IV = x.IV))': This overload of the method 'System.Linq.Queryable.Select' is currently not supported.
Remotion.Linq.Parsing.Structure.MethodCallExpressionParser.GetNodeType(MethodCallExpression expressionToParse)
Stack Query Cookies Headers Routing
NotSupportedException: Could not parse expression 'value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[OptionsAPI.Entities.Option]).Where(x => ((x.UnderlyingSymbol == "SPX") AndAlso (x.QuoteDatetime < __dt_0))).Select((x, index) => new <>f__AnonymousType0`11(index = index, UnderlyingSymbol = x.UnderlyingSymbol, QuoteDatetime = x.QuoteDatetime, Expiration = x.Expiration, Strike = x.Strike, OptionType = x.OptionType, Bid = x.Bid, Ask = x.Ask, UnderlyingBid = x.UnderlyingBid, UnderlyingAsk = x.UnderlyingAsk, IV = x.IV))': This overload of the method 'System.Linq.Queryable.Select' is currently not supported.
....