2011-02-11 74 views
1

如何將此查詢表達式語法轉換爲方法語法?請幫助,如何將此查詢表達式語法轉換爲方法語法?

var designers = (from d in _dbRead.Designer 
         join vd in _dbRead.VariationDesigner on d.DesignerId equals vd.DesignerId 
         join pv in _dbRead.ProductVariation on vd.VariationId equals pv.VariationId 
         where (pv.IsActive ?? false) && (d.SortName ?? "") != "" 
         orderby d.SortName 
         select d).Distinct(); 
+0

http://community.bartdesmet.net/blogs/bart/archive/2008/08/30/c-3-0-query-expression-translation-cheat -sheet.aspx – ullmark 2011-02-11 12:09:39

回答

3

,我沒有使用小抄here

我在另一個同種崗位上計算器的發現轉化。

這裏是soultion:

objDbread.Designer.Where(x => (x.SortName ?? string.Empty) != string.Empty).Join(objDbread.VariationDesigner, x => x.DesignerId, x1 => x1.DesignerId, (x1, x2) => new { x1, x2 }).Join(objDbread.ProductVariation, x3 => x3.x2.VariationId, x4 => x4.VariationId, (x3, x4) => new { x3, x4 }).Where(x5 => (x5.x4.IsActive ?? false)).OrderBy(x5 => x5.x3.x1.SortName).Select(x5 => x5.x3.x1).Distinct().ToList(); 
1

您需要獲得LinqPad(www.linqpad.net)的副本並將其粘貼到其中。您可以單擊一個按鈕,以查看編譯器將所有Linq查詢轉換爲的相應Method語法。

相關問題