【发布时间】:2016-11-23 07:53:01
【问题描述】:
我的 .net 应用程序中有以下功能 LINQ
public ActionResult Index()
{
Dictionary<DateTime?, List<Event>> result;
result = (from events in db.Events.Include("Activity")
where events.IsActive
group events by DbFunctions.TruncateTime(events.DateTimeFrom) into dateGroup
select new { EventDate = dateGroup.Key, Events = dateGroup.ToList() }).ToDictionary(x => x.EventDate, x => x.Events);
return View(result);
}
当我在 EF Core 中使用它时,我无法使用 DbFunctions。如何重写它以使其在 Microsoft.EntityFrameworkCore 中工作?如果这有所作为,我正在使用 SQLite。
【问题讨论】:
-
在 .Net Core 3+ 中可以使用 EF.Functions。
标签: sqlite linq entity-framework-core