C# GroupJoin在实体框架中引发错误。Join工作得很好
下面是我如何解决这个问题的C# GroupJoin在实体框架中引发错误。Join工作得很好,c#,entity-framework,lambda,C#,Entity Framework,Lambda,下面是我如何解决这个问题的 var conversationQABySubjectId = _repoWrapper.ConversationQuestionAnswer.FindAll() .Where(a => a.SubjectId == subjectId) .GroupJoin(_repoWrapper.ContactInformatio
var conversationQABySubjectId = _repoWrapper.ConversationQuestionAnswer.FindAll()
.Where(a => a.SubjectId == subjectId)
.GroupJoin(_repoWrapper.ContactInformation.FindAll(),
c => c.ResponderContactInformationIdentifier,
ci => ci.ContactInformationIdentifier,
(c, ci) => new { c, ci })
.SelectMany(cci => cci.ci.DefaultIfEmpty(), (c, ci) => new { c, ci })
.Select(m => new Tuple<Domain.TC_Context.ConversationQuestionAnswer,
Domain.TC_Context.ContactInformation>(m.c, m.ci));
var conversationQabySubject=\u repoWrapper.ConversationQuestionAnswer.FindAll()
.其中(a=>a.SubjectId==SubjectId)
.GroupJoin(_repoWrapper.ContactInformation.FindAll(),
c=>c.ResponderContactingFormationIdentifier,
ci=>ci.ContactInformationIdentifier,
(c,ci)=>新的{c,ci})
.SelectMany(m=>m.ci.DefaultIfEmpty(),(m,n)=>newtuple(m.c,n));
。GroupJoin不能单独完成左外部联接。您仍然需要.DefaultIfEmpty().SelectMany()步骤。@DevilSuichiro我添加了SelectMany和DefaultIfEmpty,但仍然得到相同的错误。任何想法由于您将.SelectMany()放在了错误的位置,m.ci是一个IEnumerable,您的元组需要一个联系人信息。@DevilSuichiro我能够修复它。。谢谢
var conversationQABySubjectId = _repoWrapper.ConversationQuestionAnswer.FindAll()
.Where(a => a.SubjectId == subjectId)
.GroupJoin(_repoWrapper.ContactInformation.FindAll(),
c => c.ResponderContactInformationIdentifier,
ci => ci.ContactInformationIdentifier,
(c, ci) => new { c, ci })
.SelectMany(cci => cci.ci.DefaultIfEmpty(), (c, ci) => new { c, ci })
.Select(m => new Tuple<Domain.TC_Context.ConversationQuestionAnswer,
Domain.TC_Context.ContactInformation>(m.c, m.ci));
var conversationQABySubjectId = _repoWrapper.ConversationQuestionAnswer.FindAll()
.Where(a => a.SubjectId == subjectId)
.GroupJoin(_repoWrapper.ContactInformation.FindAll(),
c => c.ResponderContactInformationIdentifier,
ci => ci.ContactInformationIdentifier,
(c, ci) => new { c, ci })
.SelectMany(m => m.ci.DefaultIfEmpty(), (m,n) => new Tuple<Domain.TC_Context.ConversationQuestionAnswer,
Domain.TC_Context.ContactInformation>(m.c, n));