I have following object structure where B is derived from A and I am getting input as List<A>
with lots of records. I want to convert thatList<A>
to List<B>
with easy steps (without looping). What is the best way to achieve the same.
Note: I don't want to use AutoMapper.
public class A
{
public A() { }
public virtual string Name
{
get;
set;
}
}
public class B : A
{
public B()
: base()
{
}
private string _name;
public override string Name
{
get
{
return _name;
}
set
{
_name = string.Concat("Hello ", base.Name);
}
}
public string Id
{
get { return "101"; }
}
}