C# - generic List and ConvertAll() Method, how does it internally work?
Posted
by msfanboy
on Stack Overflow
See other posts from Stack Overflow
or by msfanboy
Published on 2010-05-09T21:51:29Z
Indexed on
2010/05/09
21:58 UTC
Read the original article
Hit count: 147
Hello,
from some code I found in Sacha Barbers free mvvm framework chinch I saw this:
return new DispatcherNotifiedObservableCollection<OrderModel>(
DataAccess.DataService.FetchAllOrders(
CurrentCustomer.CustomerId.DataValue).ConvertAll(
new Converter<Order, OrderModel>(
OrderModel.OrderToOrderModel)));
FetchAllOrders
returns a List<Order>
for a certain customerID.
This list is converted to a List<OrderModel>
or in other words List<OrderViewModel>
.
How can that happen? What must be the requirements/conditions, that every property of the Order object in the List<Order>
is converted into a property of the OrderModel
?
© Stack Overflow or respective owner