无法将Linq转换为Lambda表示法

时间:2017-12-08 05:51:51

标签: c# asp.net-mvc linq

UITextView

我想将它转换为Lambda Notation.But,我无法做到。请帮助。我使用的是SupportViewModel,它包含SupportType,SupportCategory,SupportSubCategory和SupportArticle的属性。

1 个答案:

答案 0 :(得分:0)

以下是功能方式查询,你必须使用连接功能而不是获取数据

 var filteredArtciles = SupportArticles.Where(sa=> sa.ArcticleId == id);
 var query =
        SupportArticles.
         Join(SupportSubCategories,sa  =>  sa.SubCatID ,ssc => ssc.SubCatID,(sa, ssc) => new {sa,ssc}).
         Join(SupportCategories,sassc  =>  sassc.ssc.CatID ,sc=>sc.CatID ,(sassc, sc) => new {sassc,sc}).;
         Join(SupportTypes,sasscsc  => sasscsc.sc.TypeID  ,st=>st.TypeID ,(sc, st) => new {sasscsc,st}).
         Select(j=>
             new  SupportArticleViewModel 
               { 
                  supportArticle = j.sasscsc.sassc.sa, 
                  supportSubCat = j.sasscsc.sassc.ssc,
                  supportCat = j.sasscsc.sc,
                  supportType = j.st 
               }
        ));