LINQ 查询集合总的重复项
private List<FMDS_FarmPlotNewInfo> GetSame(List<FMDS_FarmPlotNewInfo> lst)
{
List<FMDS_FarmPlotNewInfo> newlst = new List<FMDS_FarmPlotNewInfo>();
newlst = (from n in lst
group n by new { subFarmID = n.SubFarmID, WorkStationID = n.WorkStationID, FarmPlotName = n.FarmPlotName, SubFarmName = n.SubFarmName, TaskAreaName=n.TaskAreaName } into g
where g.Count()>=2
select new FMDS_FarmPlotNewInfo
{
FarmPlotName=g.Key.FarmPlotName,
SubFarmID=g.Key.subFarmID,
SubFarmName=g.Key.SubFarmName,
WorkStationID=g.Key.WorkStationID,
TaskAreaName=g.Key.TaskAreaName,
}).ToList<FMDS_FarmPlotNewInfo>();
return newlst;
{
List<FMDS_FarmPlotNewInfo> newlst = new List<FMDS_FarmPlotNewInfo>();
newlst = (from n in lst
group n by new { subFarmID = n.SubFarmID, WorkStationID = n.WorkStationID, FarmPlotName = n.FarmPlotName, SubFarmName = n.SubFarmName, TaskAreaName=n.TaskAreaName } into g
where g.Count()>=2
select new FMDS_FarmPlotNewInfo
{
FarmPlotName=g.Key.FarmPlotName,
SubFarmID=g.Key.subFarmID,
SubFarmName=g.Key.SubFarmName,
WorkStationID=g.Key.WorkStationID,
TaskAreaName=g.Key.TaskAreaName,
}).ToList<FMDS_FarmPlotNewInfo>();
return newlst;
}
~奋力追求梦想的泰坦~