I recommend downloading the source code for this type of digging (NH 2.0).
First, consider the TypeFactory.HeuristicType method, which creates an instance of IType.
... else if (typeof(ICompositeUserType).IsAssignableFrom(typeClass)) { type = new CompositeCustomType(typeClass, parameters); } else if (typeof(IUserType).IsAssignableFrom(typeClass)) { type = new CustomType(typeClass, parameters); } ...
So, if your custom type implements ICompositeUserType, it gets an instance of the CompositeCustomType class. This eliminates the possibility of implementing the ICompositeUserType and IUserType interfaces.
Now consider CompositeCustomType
public override SqlType[] SqlTypes(IMapping mapping) { IType[] types = userType.PropertyTypes; SqlType[] result = new SqlType[GetColumnSpan(mapping)]; int n = 0; for (int i = 0; i < types.Length; i++) { SqlType[] sqlTypes = types[i].SqlTypes(mapping); for (int k = 0; k < sqlTypes.Length; k++) { result[n++] = sqlTypes[k]; } } return result; }
This way your types are returned from PropertyTypes and build SqlType for each property. This means that providing your own custom type types for each property will do the trick.
bbmud source share