using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
public class Plan
{
public string ProjectInfoId
{
get;
set;
}
public string CommandInfoId
{
get;
set;
}
public int value
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
List<Plan> listPlan = new List<Plan>() {
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
};
var PlanGroups =
from p in listPlan
group p by
new
{
p.ProjectInfoId,
p.CommandInfoId
}
into g
let condition = g.Sum<Plan>(t => t.value)
where condition >
select new
{
g.Key,
NumProducts = condition
};
foreach (var group in PlanGroups)
{
Console.WriteLine(string.Format("{0},{1}:{2}", group.Key.ProjectInfoId.ToString(), group.Key.CommandInfoId.ToString(), group.NumProducts));
}
}
}
}