-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Bug description
I'm mapping from one array to another array.
This code was working fine for EF 9 and it's not working in EF 10.
Do you maybe know how i can fix it?
Your code
IQueryable<NotificationFilterBase> filters = repository.GetUserFilters(userId);
var query = filters.Select(x =>
x is AlertNotificationFilter
? new
{
Strategies = ((AlertNotificationFilter)x).Strategies.Select(strategy =>
strategy == AlertStrategy.DayTrade ? NotificationFilterAlertStrategy.DayTrade :
strategy == AlertStrategy.FiveStarTrade ? NotificationFilterAlertStrategy.FiveStarTrade :
strategy == AlertStrategy.LongTerm ? NotificationFilterAlertStrategy.LongTerm :
NotificationFilterAlertStrategy.Swing
).ToArray()
} : null).ToArray();Stack traces
System.InvalidOperationException: The LINQ expression 'strategy => (int)strategy == 1 ? DayTrade : (int)strategy == 4 ? FiveStarTrade : (int)strategy == 3 ? LongTerm : Swing' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'
Verbose output
EF Core version
10
Database provider
SQL Server
Target framework
10
Operating system
Windows 11
IDE
Rider
Reactions are currently unavailable