I have two collections, and need to create a new collection from the two collections.
Assume the following class:
public class Widget
{
property int Id{get;set;}
property string Label{get;set;}
}
We have two IList classes. I would like to create an Anonymous type with Id, Label, and Exists
So doing this for Id and Label, I have:
var newCol=from w in widgets
select new {Id=w.Id,Label=w.Label,Exists=????}
Is there a way in Linq I can determine exists without writing the looping code myself here?
Edit
Exists tells us if the Widget is in the second list. So for example one solution I just thought of was:
var newCol=from w in widgets
select new {Id=w.Id,Label=w.Label,Exists=myWidgets.Contains(w)}
Where my widgets is the second IList.