Subtract a generic list from another

前端 未结 6 821
天涯浪人
天涯浪人 2020-12-13 23:02

I am trying remove a list of firmIDs from one list from another. I don\'t really understand linq but I am pretty sure I need to use it.

List firm         


        
6条回答
  •  爱一瞬间的悲伤
    2020-12-13 23:56

    I think this should works

    var result = firms.Where(x => !trackedFirms.Any(y => x.FirmID == y.FirmID));
    

    From all the firm in firms select the firm that isn't in the trackedFirms (at least this is what i understand from your question).

提交回复
热议问题