查询表达式以点表示法

时间:2011-05-19 07:15:39

标签: c# linq

hei,需要一些帮助才能将此linq查询转换为点符号:

            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 }
            };

2 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:1)

好。如果你的意思是Linq的流利符号(你说的是“dot net”,两者都是dot net(.NET))我认为这应该可以解决问题:

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