I have a problem that I either don't understand or which isn't currently
supported by the iBATIS DataMapper (v.1.6.1). Any insight or
recommendations are greatly appreciated.
I use a heavily customized, generic BindingList as the collection for all of
my entity classes. For reference, the type and its super-class are shown
below:
public class TList<T> : ListBase<T> where T : IEntity, new()
public abstract class ListBase<T> :
BindingList<T>, IBindingListView, IBindingList,
IList, ICloneable, IListSource, ITypedList,
IDisposable, IComponent, IRaiseItemChangedEvents,
IDeserializationCallback
If we use the traditional Northwind-based example, I have the following
sqlMap alias section in the config file associated with the Category
entity/table:
<sqlMap namespace="Northwind.Entities.Categories" . . . >
<alias>
<typeAlias alias="Instance" type="Northwind.Entities.Categories,
Northwind.Entities" />
<typeAlias alias="List"
type="Northwind.Entities.TList<Categories>, Northwind.Entities" />
</alias>
. . .
</sqlMap>
When I try to initialize the mapper instance like so:
ISqlMapper map = Mapper.Instance();
I get the following inner exception:
"Could not load type from string value
'Northwind.Entities.TList<Categories>, Northwind.Entities'.":""
I am guessing that the issue has to do with how the SqlMapper is using
reflection to check/instantiate each typeAlias. The reflection code for
dealing with generics is a bit more involved than a simple
Assembly.LoadFrom() and Assembly.CreateInstance(). More details with an
example can be seen here:
http://msdn2.microsoft.com/en-us/library/b8ytshk6.aspx
While I can probably get around this issue by having "collection classes"
that inherit from a typed-instance of my TList<T>, it sort of defeats much
of the purpose of the generic concept. Is there something I am missing? Is
there a way to do this without "hacking around" it?
Tony