【发布时间】:2015-03-05 19:36:10
【问题描述】:
我无法执行此错误“非静态方法需要一个目标”。而且我不确定为什么会出现此错误。 下面的查询中有四个表,其中一个连接和两个左外连接。最后一个遗漏连接可能包含要匹配的空行
var model = from p in Uow.Instance.RepoOf<RoleMenuMetrix>().GetAll()
from n in Uow.Instance.RepoOf<NavigationMenu>().GetAll().Where(q => q.Id == p.MenuId)
from m in
Uow.Instance.RepoOf<NavigationButton>()
.GetAll()
.Where(q => q.NavigationMenuId == n.Id)
.DefaultIfEmpty()
from o in // when I comment this from it works fine, but i donot get the values from this table.
Uow.Instance.RepoOf<RoleButtonMatrix>().GetAll().Where(q => q.ButtonId == m.Id).DefaultIfEmpty()
where p.RoleId == Guid.Parse("96246E99-6BF2-4A3D-8D2C-263DDEF2F97B")
&& n.IsActive && n.ApplicationName == "MEM"
select new
{
p.MenuId,
p.RoleId,
n.Name,
n.ParentId,
ButtonName = m != null ? m.ButtonName : String.Empty,
ButtonId = m != null ? m.Id : 0,
ischecked = o.RoleId == "96246E99-6BF2-4A3D-8D2C-263DDEF2F97B" ? "true" : "false"//// when I comment this it works fine, but i do not get the values from this table
};
它从模型变量生成的错误屏幕截图
以下是所需的预期输出
【问题讨论】:
-
请显示exact错误信息,包括它引用的代码部分。
-
以后,请将错误消息的文本作为文本。阅读这样的小屏幕截图要困难得多。在这种情况下,只是解释这是一个异常并显示完整的堆栈跟踪会有所帮助......尽管这完全有可能只是一个调试器问题。尝试在应用中实际显示结果时是否遇到异常?
-
我无法在我的模型“model.Where(q => q.ParentId == null).ToList();”上执行此操作当我评论提到的行时,它工作正常。但我需要这些行来执行左外连接
-
我不明白这如何回答我的评论...
-
@JhonSkeet 否我在“model.Where(q => q.ParentId == null).ToList()”中收到错误它没有成功显示结果。它在上面提到的代码中崩溃。该错误与代码行中定义的相同。如果您还有其他问题,请告诉我
标签: c# linq linq-to-entities linqpad