Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
DataMapper 1.6.1
-
None
Description
In the IBatisNet.DataMapper.DataExchange.DotNetObjectDataExchange class the method public override void SetData(ref object target, ResultProperty mapping, object dataBaseValue)
does a check against types using this statement:
if ((type != this._parameterClass) && !type.IsSubclassOf(this._parameterClass))
The problem here is that IsSubclassOf doesn't check for interface implementations. When _parameterClass is an interface you also need to check using
type.GetInterfaces().Contains(this._parameterClass)
This would then allow for result mappings to use interfaces, which is really useful when you are using an IoC container to instantiate the class being populated, for example:
ISale sale = Container.Resolve<ISale>();
...
Mapper.Instance().QueryForObject<ISale>("uspSelectSale", saleNumber, sale);
Thanks