Код: Выделить всё
// Create a list of anonymous objects that combine the three fields for comparison
var subscriptionKeys = subscriptions
.Select(s => new { s.UserId, s.NotificationType, s.Channel })
.ToList();
// Fetch all existing subscriptions where the combination of UserId,
NotificationType, and Channel match
var existingSubscriptions = await this.context.Subscriptions
.Where(s => subscriptionKeys.Contains(new { s.UserId, s.NotificationType,
s.Channel })).ToListAsync();
Код: Выделить всё
System.InvalidOperationException HResult=0x80131509 Message=The LINQ expression '__subscriptionKeys_0
.Contains(new {
UserId = StructuralTypeShaperExpression:
Micro.NotificationService.Models.Subscription
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.UserId,
NotificationType = StructuralTypeShaperExpression:
Micro.NotificationService.Models.Subscription
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.NotificationType,
Channel = StructuralTypeShaperExpression:
Micro.NotificationService.Models.Subscription
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.Channel
})' 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'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information. Source=Microsoft.EntityFrameworkCore StackTrace: at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression)
Подробнее здесь: https://stackoverflow.com/questions/789 ... y-3-fields