Imagine four lists, all at least have this Id string property, but may have other properties:
public class A //or B, C, D
{
public string Id { get; set; }
//..other properties
}
//so:
List<A> a1 = new List<A>();
List<B> a2 = new List<B>();
List<C> a3 = new List<C>();
List<D> a4 = new List<D>();
I want to select all DISTINCT ids in:
a1, combined with a2, a3 and a4
I thought LINQ syntax would be ideal but how do you combine these to an IEnumerable result with a single string property, for example something with a definition of class A.
Are they really all lists of the same type? Or do you have
and you want to combine those because all 4 types have a common string Id property?
OK, your edit shows I was on the right track. You need an Interface that defines the string Id property and each type A, B, C and D need to implement that Interface.
Then each list will be of the Interface type and the concat answers will work.
If you don’t have ability to define the interface, then you could use LINQ to query each list for only the Id field (you should get
IQueryable<String>results) and then concat those results.Edit: Here’s a LINQ query that should give you what you’re looking for: