加入LINQ-to-Entities [英] JOIN with LINQ-to-Entities
问题描述
我有一个LINQ-SQL查询,我需要将其转换为LINQ-Entity。
var的结果=来自上下文中的意图.InterestedEntity
在上下文中加入c。意图使用。 Case.CaseID等于c.CaseID到cas1中来自c中的cas1.DefaultIfEmpty()
在上下文中加入pers.Person对intent.Entity.EntityID等于pers.Entity.EntityID到pers1中来自pers in pers1.DefaultIfEmpty()
join in context.Entity on intent.Entity.EntityID将ent.EntityID等于ent1从ent1中的ent1.DefaultIfEmpty()
在上下文中加入pa。 intent.Entity.EntityID上的PostalAddress等于pa.Entity.EntityID到pa1中from pa in pa1.DefaultIfEmpty()
其中
c.CaseID == caseID
选择新的{
CaseID = c.CaseID,
InterestedEntitiesID = intent.InterestedEntityID,
PersonID = pers.PersonID
}
有人可以帮我写一个等效的Entity-SQL查询作为"DefaultIfEmpty()"不工作?
我是否必须求助于实体SQL来实现这个目标?
我有一个LINQ-SQL查询,我需要将其转换为LINQ-Entity。
var result = from intent in context.InterestedEntity
join c in context.Case on intent.Case.CaseID等于c.CaseID到cas1中来自c中的cas1.DefaultIfEmpty()
在上下文中加入pers.Person on intent.Entity.EntityID等于pers.Entity.EntityID到pers1
from pers in pers1.DefaultIfEmpty()
join in context.Entity on intent.Entity.EntityID equals ent.EntityID into ent1
from ent in ent1.DefaultIfEmpty()
在上下文中加入pa。关于intent.Entity.EntityID的paostalAddress等于pa.Entity.EntityID到pa1中,来自pa中的pa .DefaultIfEmpty()
其中
c.CaseID == caseID
选择新的{
CaseID = c.CaseID,
InterestedEntitiesID = intent.InterestedEntityID,
PersonID = pers.PersonID
}
有人可以帮助我为此编写等效的Entity-SQL查询,作为"DefaultIfEmpty()"不工作?
我是否必须求助于Entity SQL才能实现这一目标?¥
b 我决定了继续创建一个存储过程,我有一个具有外连接的复杂查询。
但是当我使用EDMGEN.exe导入SP时,我在CSDL和MSL文件中找不到所需的映射。
我必须手动添加这些映射吗?
谢谢。!
I have a LINQ-SQL query which I need to convert to LINQ-Entity.
var results = from intent in context.InterestedEntity
join c in context.Case on intent.Case.CaseID equals c.CaseID into cas1
from c in cas1.DefaultIfEmpty()
join pers in context.Person on intent.Entity.EntityID equals pers.Entity.EntityID into pers1
from pers in pers1.DefaultIfEmpty()
join ent in context.Entity on intent.Entity.EntityID equals ent.EntityID into ent1
from ent in ent1.DefaultIfEmpty()
join pa in context.PostalAddress on intent.Entity.EntityID equals pa.Entity.EntityID into pa1
from pa in pa1.DefaultIfEmpty()
where
c.CaseID == caseID
Select new {
CaseID = c.CaseID,
InterestedEntitiesID = intent.InterestedEntityID,
PersonID = pers.PersonID
}
Can somebody help me to write equivalent Entity-SQL query for this as "DefaultIfEmpty()" wont work?
Do the I have to resort to Entity SQL to achieve this?
解决方案I have a LINQ-SQL query which I need to convert to LINQ-Entity.
var results = from intent in context.InterestedEntity
join c in context.Case on intent.Case.CaseID equals c.CaseID into cas1
from c in cas1.DefaultIfEmpty()
join pers in context.Person on intent.Entity.EntityID equals pers.Entity.EntityID into pers1
from pers in pers1.DefaultIfEmpty()
join ent in context.Entity on intent.Entity.EntityID equals ent.EntityID into ent1
from ent in ent1.DefaultIfEmpty()
join pa in context.PostalAddress on intent.Entity.EntityID equals pa.Entity.EntityID into pa1
from pa in pa1.DefaultIfEmpty()
where
c.CaseID == caseID
Select new {
CaseID = c.CaseID,
InterestedEntitiesID = intent.InterestedEntityID,
PersonID = pers.PersonID
}
Can somebody help me to write equivalent Entity-SQL query for this as "DefaultIfEmpty()" wont work?
Do the I have to resort to Entity SQL to achieve this?
I decided to go with creating a Stored Procedure where ever I have a complex query that has outer joins.
But when I import SP using EDMGEN.exe, I dont find the required mapping in CSDL and MSL files.
Do I have to manually add these mappings?
Thanks.!
这篇关于加入LINQ-to-Entities的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!