我试图根据列表中的项目来构建项目列表。按对象属性从列表中排除项目
itemsAll
包含所有的产品itemsNew
只包含新产品- 我想
itemsOld
只包含老产品(即itemsAll
-itemsNew
)
这是我的方法,这不会返回正确数量的项目。
var itemsAll = objProductStagingRepository.AllImports(fileId, cid).ToList();
var itemsNew = objProductStagingRepository.DetectNonPresentProductNames(fileId, cid).ToList();
var itemsOld = from t1 in itemsAll where !(from o in itemsNew select o.Id).Contains(t1.Id)
select t1; // this does not work
有没有人有任何建议,我应该怎么适应这个?我试过itemsAll.Except(itemsNew)
,这也不会产生正确的结果!