0

私は以下のSQLクエリを持っています

Select LC.*,LP.[LandingPageName] from [LandingPageCompanies] LC
 Left join [LandingPageContent] LP on LP.SubCategoryID=LC.SubCategoryID
 where  LC.[CategoryID]=17

そして、私はそれをに変換する必要がありLINQ to entityます。

次のクエリを試しましたが、次のように機能していますInner join

 var data = (from t1 in dbSavingContainer.LandingPageCompanies
                        join t2 in dbSavingContainer.LandingPageContents on t1.SubCategoryID equals t2.SubCategoryID
                        where t1.CategoryID == CategoryID
                        select new
                        {
                            CategoryID = t1.CategoryID,
                            CompanyID = t1.CompanyID,
                            CompanyLink = t1.CompanyLink,
                            CompanyLogo = t1.CompanyLogo,
                            CompanyName = t1.CompanyName,
                            SubCategoryID = t1.SubCategoryID,
                            LandingPageName = t2.LandingPageName
                        }).ToList();

私が欠けているところ。?

4

1 に答える 1

1

ありがとう..私は以下のクエリを使用して解決しました;)

 var data = (from t1 in dbSavingContainer.LandingPageCompanies
             join t2 in dbSavingContainer.LandingPageContents on t1.SubCategoryID equals t2.SubCategoryID
             into x from y in x.DefaultIfEmpty()
                   where t1.CategoryID == CategoryID
                     select new
                      {
                        CategoryID = t1.CategoryID,
                        CompanyID = t1.CompanyID,
                        CompanyLink = t1.CompanyLink,
                        CompanyLogo = t1.CompanyLogo,
                        CompanyName = t1.CompanyName,
                        SubCategoryID = t1.SubCategoryID,
                        LandingPageName = y.LandingPageName
                    }).ToList();
于 2013-03-22T11:37:17.507 に答える