Query expression to dot notation
hei, need some help to c开发者_高级运维onvert this linq query to dot notation:
var productions =
from row in data
group row by row.PRODUCTION_NAME into gr
select new
{
Group = gr.Key,
Jobs = from row in gr
orderby row.SortFieldCard
group row by row.JOB_NAME into job
select new { job.Key, Cards = job }
};
var productions = data
.GroupBy(row => row.PRODUCTION_NAME)
.Select(gr => new
{
Group = gr.Key,
Jobs = gr
.OrderBy(row => row.SortFieldCard)
.GroupBy(row => row.JOB_NAME)
.Select(job => new { job.Key, Cards = job })
});
Well. If you mean fluent notation of Linq (you said "dot net", and both are dot net (.NET)) I think this should do the trick:
var productions = data
.GroupBy(row => row.PRODUCTION_NAME)
.Select(gr => new {
Group = gr.Key,
Jobs = gr
.OrderBy(row => row.SortFieldCard)
.GroupBy(row => row.JOB_NAME)
.Select(job => new { job.Key, Cards = job})
});
精彩评论