Jen143 Jen143 - 6 months ago 76
MySQL Question

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

enter image description here

Error Message:
((System.Data.Entity.DynamicProxies.Task_6F777A6C52D9E84FD3DF53481564A61969CE62ABBA9D985448F99BFB8A49A2D7)new System.Collections.Generic.Mscorlib_CollectionDebugView<oRouter.Model.Task>(task).Items[0]).TaskPlugins



One thing, You should be returning tasks.ToList() and not 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.