[英]Join table in Entity framework
I'll have this query in joining the table but it did not returned data from Include table or Join table. 我将在联接表中使用此查询,但是它没有从包含表或联接表中返回数据。
var tasks = (from item in ctx.Tasks
join tp in ctx.TaskPlugins
on item.TaskId equals tp.TaskId
select item)
.Include(x => x.TaskPlugins).Include(x => x.TaskPlugins.Select(p => p.Plugin)).Include(x=>x.TaskPlugins.Select(p=>p.Plugin.Store));
return ctx.Tasks.ToList();
But this query does not return data from TaskPlugins
但是此查询不会从TaskPlugins
返回数据
Error Message: ((System.Data.Entity.DynamicProxies.Task_6F777A6C52D9E84FD3DF53481564A61969CE62ABBA9D985448F99BFB8A49A2D7)new System.Collections.Generic.Mscorlib_CollectionDebugView<oRouter.Model.Task>(task).Items[0]).TaskPlugins
错误消息: ((System.Data.Entity.DynamicProxies.Task_6F777A6C52D9E84FD3DF53481564A61969CE62ABBA9D985448F99BFB8A49A2D7)new System.Collections.Generic.Mscorlib_CollectionDebugView<oRouter.Model.Task>(task).Items[0]).TaskPlugins
Thanks. 谢谢。
One thing, You should be returning tasks.ToList()
and not ctx.Tasks.ToList()
一件事,您应该返回tasks.ToList()
而不是ctx.Tasks.ToList()
Second, the last include .Include(x=>x.TaskPlugins.Select(p=>p.Plugin.Store)
is the only one needed. First 2 includes are NOT needed. 第二,最后包括.Include(x=>x.TaskPlugins.Select(p=>p.Plugin.Store)
是所需要的唯一的一个。首先2包括是不需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.