The fake code is:
public class ParentClass
{ decimal quantity,
decimal price
}
IQueryable<ParentClass> parents;
//SonClass is created at run time
//SonClass has some extra property, such as amount=quantity*price, which is defined by a string at run time
IQueryable<SonClass> sons=parents.Select(p=>new SonClass(p){ attachedProperty1=..., attachedProperty2=...})
If I have the source code of ParentClass, I know how to create the sonClass at run time. Actually SonClass should have a suitable constructor for the Linq select statement. I tried the following fake code:
public SonClass(ParentClass parent)
{
...
}
When we don't have the source code of ParentClass, how to write a generic code ?
Or, maybe you have a new way to get the same result. The desired results is to create a subclass of ParentClass dynamically with extra read only properties defined by Linq Select statement.
Thank you in advance.
Ying