Hi,
I use C# 3.5 DotNet Framework and Linq.
I have 2 Views which have the same result-schema, but in linq that are different objects of course.
How can I convert List a to List b?
Hi,
I use C# 3.5 DotNet Framework and Linq.
I have 2 Views which have the same result-schema, but in linq that are different objects of course.
How can I convert List a to List b?
You can create a new list of B's:
List<B> listOfB = listOfA.Select(a => new B {
Foo = a.Foo,
Bar = a.Bar,
// etc...
}).ToList();
When they have the same structure, try take a look at AutoMapper.
With AutoMapper you can do something like this:
Mapper.CreateMap<Source, Destination>();
List<Destination> listDest = Mapper.Map<Source[], List<Destination>>(sources);