I'm just getting my feet wet with LINQ. Given three lists of items, this is what I've come up with to only show ClassA items that are referenced in the list of ClassB items but not in the list of ClassC items.
var uniqueClassAIDsInClassB =
(from classB in classBList
select classB.ClassAID).Distinct();
var uniqueClassAIDsInClassC =
(from classC in classCList
select classC.ClassAID).Distinct();
var classAListFiltered =
from classA in GetClassAList()
where uniqueClassAIDsInClassB.Contains(classA.ID)
!uniqueClassAIDsInClassC.Contains(classA.ID)
select classA;
The resulting list is used as a datasource for a dropdownlist. What's a cleaner/better way to do this?