c# - Pass type to generic method (nested generic) -
how can invoke following method while have not trootentity, have type:
public void class<trootentity>(action<iclassmapper<trootentity>> customizeaction) trootentity : class;
final goal run following code
var mapper = new modelmapper(); mapper.class<myclass>(ca => { ca.id(x => x.id, map => { map.column("myclassid"); map.generator(generators.highlow, gmap => gmap.params(new { max_low = 100 })); }); ca.property(x => x.something, map => map.length(150)); }); it used create dynamic nhibernate hbm. more info available here
you cannot code generic methods run passing runtime type.
generics need have type @ compile time.
you may need use reflection (see answer of mr. ferreira point on how that).
Comments
Post a Comment