开发者

how do i convert this query expression syntax to method syntax?

How do i convert this query expression syntax to method syntax? please help,

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


i did the conversion using the cheat sheet here

Which i found in another of the same kind of post on stackoverflow.

Here is the 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();


You need to get a copy of LinqPad (www.linqpad.net) and paste your query into it. There is a button that you click that allows you to see the corresponding Method syntax, which the compiler converts all Linq queries to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜