Asp.net mvc LINQ选择项目不在列表中的位置

Asp.net mvc LINQ选择项目不在列表中的位置,asp.net-mvc,linq,asp.net-mvc-3,linq-to-entities,Asp.net Mvc,Linq,Asp.net Mvc 3,Linq To Entities,我需要插入不在db中的项。因此,我尝试运行以下不起作用的程序: foreach(var rep in model.Reps.Where(x => x.Value != this.dictionaryItemRepository.List().Select(y => y.Value))) 其中model.Reps为: public ICollection<DictionaryItemBrand> Reps { get; set; } 从模型活页夹返回 我正

我需要插入不在db中的项。因此,我尝试运行以下不起作用的程序:

 foreach(var rep in model.Reps.Where(x => x.Value != 
    this.dictionaryItemRepository.List().Select(y => y.Value)))
其中model.Reps为:

 public ICollection<DictionaryItemBrand> Reps { get; set; }
从模型活页夹返回

我正在尝试执行foreach循环->从model.Rep中选择存储库中尚不存在的所有项目

我怎么做? 谢谢

应该就是这个了

var notInRepo = from rep in model.Reps
                where (!this.dictionaryItemRepository.Contains(rep.Value))
                select rep.Value;