NCCSBIM071
NCCSBIM071

Reputation: 1205

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

Upvotes: 1

Views: 616

Answers (2)

NCCSBIM071
NCCSBIM071

Reputation: 1205

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

Upvotes: 3

Randy Minder
Randy Minder

Reputation: 48542

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.

Upvotes: 1

Related Questions