日期:2014-05-20 浏览次数:21051 次
static void Main(string[] args)
{
var stationIDs = new List<int> { 1, 2, 3, 4 };
var stations = new List<Station>{
new Station{ StationID=1, Type=0},
new Station{ StationID=2, Type=1},
new Station{ StationID=3, Type=1},
new Station{ StationID=4, Type=1},
new Station{ StationID=2, Type=0},
new Station{ StationID=1, Type=0}
};
var result = from c in stationIDs
join o in
from c in stations
where c.Type == 0
select c on c equals o.StationID into ords
select new
{
c,
count = ords.Count()
};
foreach (var item in result)
{
Console.WriteLine("{0}", item);
}
Console.Read();
}