c# - linq to sql Distinct and orderby -
var result = table1.join(table2, o => o.programid, t => t.programid, (o, t) => new { o.programid, t.program }) .orderby(t => t.program) .distinct();
the above linq statement returns correct result, sql generated (below) not simple be
select [t2].[programid], [t2].[program] ( select distinct [t0].[programid], [t1].[program] [table1] [t0] inner join [table2] [t1] on [t0].[programid] = [t1].[programid] ) [t2] order [t2].[program]
i have thought sql below far cleaner i'm not sure of linq statement achieve it.
select distinct o.programid, t.program table1 0 inner join table2 t on t.programid = o.programid order t.program
thanks in advance
i don't know if help, can try this;
var result = (from o in table1 join t in table2 on o.programid equals t.programid orderby t.program select new { o.programid, t.program }).distinct();
Comments
Post a Comment