Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# GroupJoin在实体框架中引发错误。Join工作得很好_C#_Entity Framework_Lambda - Fatal编程技术网

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));