Is there a way to transfrom a list of key/value pairs into a data transfer object
Posted
by weevie
on Stack Overflow
See other posts from Stack Overflow
or by weevie
Published on 2010-03-30T08:31:11Z
Indexed on
2010/03/30
8:33 UTC
Read the original article
Hit count: 260
...apart from the obvious looping through the list and a dirty great case statement!
I've turned over a few Linq queries in my head but nothing seems to get anywhere close.
Here's the an example DTO if it helps:
class ClientCompany
{
public string Title { get; private set; }
public string Forenames { get; private set; }
public string Surname { get; private set; }
public string EmailAddress { get; private set; }
public string TelephoneNumber { get; private set; }
public string AlternativeTelephoneNumber { get; private set; }
public string Address1 { get; private set; }
public string Address2 { get; private set; }
public string TownOrDistrict { get; private set; }
public string CountyOrState { get; private set; }
public string PostCode { get; private set; }
}
We have no control over the fact that we're getting the data in as KV pairs, I'm afraid.
© Stack Overflow or respective owner