开发者

LINQ select where item is not in list

i need to insert items that are not in db. so i'm trying to run the following (which doesn't work):

 foreach(var rep in model.Reps.Where(x => x.Value != 
    this.dicti开发者_Go百科onaryItemRepository.List().Select(y => y.Value)))

where model.Reps is:

 public ICollection<DictionaryItemBrand> Reps { get; set; }

returned from model binder

I'm trying to do a foreach loop -> select all items from model.Reps that do NOT yet exist in repository.

how can i do it? thanks


This should be it.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜