Группировка Entity Framework по коллекции памятиC#

Место общения программистов C#
Гость
Группировка Entity Framework по коллекции памяти

Сообщение Гость »


У меня есть table with columns , and .
There is an in-memory collection that has Code-Phase value pairs:

Код: Выделить всё

T100 - 1
,

Код: Выделить всё

L100 - 1
,

Код: Выделить всё

T200 - 2
... multiple codes can map to same phase number.
Getting the totals per code is simple.

Код: Выделить всё

 var totals = db.Items.GroupBy(x => x.Code)
.Select(x => new
{
Code = x.Key,
Total = x.Sum(y => y.Amount),
});
Is it possible to have a query in EF that finds the total amounts by phase number?
I know that combining in memory collections and EF

Код: Выделить всё

IQuerable
is not possible in general. I was hoping to do this without converting the DbSet to

Код: Выделить всё

IEnumerable
.


Источник: https://stackoverflow.com/questions/781 ... collection

Вернуться в «C#»