У меня есть класс с именем ServiceDayWithEmployee, который содержит список других классов DaysWithSubCount здесь как оба класса похож ...Исключение из «System.NotSupportedException» типа при получении данных в entityframe
public class ServiceDayWithEmployee
{
public int shiftID { get; set; }
public string shiftName { get; set; }
public int serviceDaysCount { get; set; }
public List<DaysWithSubCount> days{ get; set; }
}
public class DaysWithSubCount
{
public int count { get; set; }
public DateTime date { get; set; }
}
Я привязка для запуска запроса для заполнения ServiceDayWithEmployee из базы данных, включая список дней.
Я делаю так в цикле Еогеасп как следующее ...
foreach(shift sh in shifts)
{
ServiceDayWithEmployee SDE= new ServiceDayWithEmployee();
SDE.shiftID=sh.id;
SDE.shiftName=sh.shift_name;
SDE.days = fleet.subscribtion_dates.Where(x => x.shift.Equals(sh.id)).GroupBy(x => x.date).Select(grp => new DaysWithSubCount { date = grp.Key.Value, count = grp.Count() }).ToList();
SDE.serviceDaysCount=SDE.days.Count;
SDEs.Add(SDE);
}
Эта строка кода дает мне исключение и если я уаг запрос вместо SDE.days и удалить .ToList() он не падает, но я не знаю, как заполнить список дней.
SDE.days = fleet.subscribtion_dates.Where(x => x.shift.Equals(sh.id)).GroupBy(x => x.date).Select(grp => new DaysWithSubCount { date = grp.Key.Value, count = grp.Count() }).ToList();
Вот исключение ... как выражение не может быть переведен на SQL
An exception of type 'System.NotSupportedException' occurred in System.Data.Entity.dll but was not handled in user code
Additional information: Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.