I have an object like this -
public MyObject
{
public int Id { get; set; }
public string MyType { get; set; }
}
a list of those objects -
public List<MyObject> MyObjectList { get; set; }
and a list of string like this -
public List<string> MyTypeList { get; set; }
Using LINQ on MyObjectList, I want to create a list of MyObject removing any MyObject that has a MyObject.MyType that is in the MyTypeList.
Something like this (here are some unsuccessful attempts) -
List<MyObject> MyObjectListNEW = MyObjectList.Select(i => i.MyType).Except(MyTypeList).ToList();
List<MyObject> MyObjectListNEW = MyObjectList.Where(i => i.MyType.Except(MyTypeList));
List<MyObject> MyObjectListNEW = MyObjectList.Where(i => !MyTypeList.Any( t => t == i.MyType)).ToList();