Assume following:
public class MyFunkyTable : DbObject
{
// this class will be generated
}
public class MyFunkyDomainObject : DomainObject
{
// this class will be custom-made
}
public class MyFunkyMapper : Mapper<MyFunkyTable, MyFunkyDomainObject>
{
// this will be custom mapping code due to wired abstraction and ... "supercool" db-system
}
in general we do following:
MappingHelper<MyFunkyTable, MyFunkyMapper, MyFunkyDomainObject>.GetSingle(...);
bu the repeating of the generic constraints is a bit an cumbersome (MyFunkyMapper already specifies the generics..)
Is there any way to do something like:
MappingHelper<MyFunkyMapper>.GetSingle(..);
edit:
I’ve already came up with an idea: usage of extension methods, but this isn’t what I want…
Why don’t you just do something like
This assumes that
Mapper<TTable, TDomain>has aGetSingle<TDomain>(...)method. If this is the case, type inference will figure out the generic argument to GetSingle even if you don’t write it.BTW, have you considered using AutoMapper for mapping purposes instead of rolling your own?