2017-09-14 3 views
0
model.ListManagerReviewerMapping = (from a in wallet.OM_Employee 
            join m in wallet.APPR_ManagerMapping 
            on a.AssociateId equals m.AssociateId 
            where m.ManagerId==Context.UserId.Value **into** MM 
            from leftjoinresult in M.DefaultIfEmpty() 
            where a.CompanyId == Context.CompanyId && (a.TermStatus == "L" || a.SeparationDate > DateTime.Today) 
            select new ManagerAndReviewerMappingModel.ManagerAndReviewerMapping() 
            { 
             Photo = (photoUrl + "?AssociateCode=" + a.AssociateCode), 
             AssociateId = a.AssociateId, 
             AssociateCode = a.AssociateCode, 
             AssociateName = a.AssociateName 
            }).ToList(); 
+0

読めるようにしてコードをフォーマットしてください。ヒント:4つ分のスペースをインデントします。そして、実際に問題や疑問は何ですか? –

+0

質問または問題は何ですか? –

+0

** into **エラーを取得するクエリボディはLINQのselect句またはグループ句で終了する必要があります。クエリ –

答えて

1

は(あなたができることに注意してください」DefaultIfEmptyに参加しますwhereがクエリを完了するためにselectに従わなければならないので、T)where句の後intoを使用します。

model.ListManagerReviewerMapping = (from a in wallet.OM_Employee 
            join m in wallet.APPR_ManagerMapping.Where(x => x.ManagerId == Context.UserId.Value) 
            on a.AssociateId equals m.AssociateId into MM 

            from leftjoinresult in MM.DefaultIfEmpty() 
            where a.CompanyId == Context.CompanyId && (a.TermStatus == "L" || a.SeparationDate > DateTime.Today) 
            select new ManagerAndReviewerMappingModel.ManagerAndReviewerMapping() 
            { 
             Photo = (photoUrl + "?AssociateCode=" + a.AssociateCode), 
             AssociateId = a.AssociateId, 
             AssociateCode = a.AssociateCode, 
             AssociateName = a.AssociateName 
            }).ToList(); 

同様の問題:

を0

LINQ LEFT JOIN where clause not working

LINQ Left Join And Right Join

+0

それは私のために働くありがとう –

1
//Remove brackets and .ToList(); 
model.ListManagerReviewerMapping = from a in wallet.OM_Employee 
           join m in wallet.APPR_ManagerMapping 
           on a.AssociateId equals m.AssociateId 
           where m.ManagerId==Context.UserId.Value **into** MM 
           from leftjoinresult in M.DefaultIfEmpty() 
           where a.CompanyId == Context.CompanyId && (a.TermStatus == "L" || a.SeparationDate > DateTime.Today) 
           select new ManagerAndReviewerMappingModel.ManagerAndReviewerMapping() 
           { 
            Photo = (photoUrl + "?AssociateCode=" + a.AssociateCode), 
            AssociateId = a.AssociateId, 
            AssociateCode = a.AssociateCode, 
            AssociateName = a.AssociateName 
           }; 
関連する問題