How can I invoke following method while I have not TRootEntity
, but have just its TYPE
:
public void Class<TRootEntity>(Action<IClassMapper<TRootEntity>> customizeAction) where TRootEntity : class;
final goal is to 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 is used to create dynamic NHibernate HBM
. More info available here
As related question see here and here.
You cannot code Generic methods to run by passing a runtime Type.
Generics need to have the type at compile time.
You may need to use reflection (see answer of mr. Ferreira that point on how to do that).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With