C# linq to sql lambda表达式上的新手,其中两个后面的语句包括

C# linq to sql lambda表达式上的新手,其中两个后面的语句包括,c#,linq,lambda,C#,Linq,Lambda,这不是工作原理。您要改为使用: var Query2=来自CoreDatabase.Set()中的 在a.id equalas b.id上的CoreDatabase.Set()中加入b 在b.fkid等于c.id的CoreDatabase.Set()中加入c 其中c.appapplicationname==“MshHumanResources” 选择一个; 这只是从中选择列-如果要从其他表中选择列,请创建一个类来组合所需的字段或使用匿名类型。尝试以下操作: var Query2 = from

这不是工作原理。您要改为使用:

var Query2=来自CoreDatabase.Set()中的
在a.id equalas b.id上的CoreDatabase.Set()中加入b
在b.fkid等于c.id的CoreDatabase.Set()中加入c
其中c.appapplicationname==“MshHumanResources”
选择一个;
这只是从中选择列-如果要从其他表中选择列,请创建一个类来组合所需的字段或使用匿名类型。

尝试以下操作:

var Query2 = from a in CoreDatabase.Set<tblPerson>()
             join b in CoreDatabase.Set<tblApplicationInterface>() on a.id equlas b.id
             join c in CoreDatabase.Set<tblApplicationName>() on b.fkid equals c.id
             where c.AppplicationName == "MshHumanResources"
             select a;
var Query2=CoreDatabase.Set
.包括(“tblApplicationInterface”)
.Include(“tblApplicationInterface.tblApplicationName”)
。其中(x=>x.ApplicationName==“MshHumanResources”);

你可以直接说

var Query2 = CoreDatabase.Set<tblPerson>
                 .Include("tblApplicationInterface")
                 .Include("tblApplicationInterface.tblApplicationName")
                 .Where(x => x.ApplicationName == "MshHumanResources");
var people=CoreDatabase.Set()。其中(p=>
p、 tblApplicationInterface.tblApplicationName.ApplicationName==“MshHumanResources”);

如果我正确理解您的导航属性。这将选择应用程序界面的应用程序名为MshHumanResources的人员。

如果您尝试执行sql,为什么要从tblPerson集中进行选择?但它不会从TBLApplicationInterface和tblApplicationNameTrue加载数据,此时您只有一个tblPerson对象。如果您还想填写导航属性,您需要答案中的include。不过,如果我正确阅读了导航属性并记住include是如何工作的,我认为这里的where子句更准确。实际上,我认为如果您引用它们,linqtosql将填充它们。但是,正如我所记得的,include接受一个字符串参数,而不是lambda,所以我不完全确定它引用的是什么ORM。这是如何工作的呢?acct=DataContext.BrokerageAccounts.include(“tblPersons”).include(“tblApplicationInterface”).include(“tblApplicationInterface.tblApplicationName”).SingleOrDefault(ba=>ba.ApplicationName==“MSH”);我似乎无法。包括(x=>x.tblApplicationInterface.tblApplicationName)该行可能Linq to SQL不允许lambda表达式作为包含参数。我将答案更改为使用文本。如果删除where语句,我将获得一个包含上述语句的内部联接查询。。。。
var Query2 = from a in CoreDatabase.Set<tblPerson>()
             join b in CoreDatabase.Set<tblApplicationInterface>() on a.id equlas b.id
             join c in CoreDatabase.Set<tblApplicationName>() on b.fkid equals c.id
             where c.AppplicationName == "MshHumanResources"
             select a;
var Query2 = CoreDatabase.Set<tblPerson>
                 .Include("tblApplicationInterface")
                 .Include("tblApplicationInterface.tblApplicationName")
                 .Where(x => x.ApplicationName == "MshHumanResources");
var people = CoreDatabase.Set<tblPerson>().Where( p => 
p.tblApplicationInterface.tblApplicationName.ApplicationName == "MshHumanResources" );