ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Selke" <tse...@liquidhub.com>
Subject RE: <typeAlias> support for C# Generics?
Date Thu, 31 May 2007 15:27:47 GMT
That syntax appears to have gotten me past that error, thank you!




From: EXT / ASTEK MOUSSON Nicolas [mailto:ext.astek.mousson@sncf.fr] 
Sent: Thursday, May 31, 2007 11:19 AM
To: user-cs@ibatis.apache.org; tselke@liquidhub.com
Subject: RE : <typeAlias> support for C# Generics?



To use your generic class with iBATIS, just use the following syntax in your



    <typeAlias alias="List"
Northwind.Entities" />





-----Message d'origine-----
De : Clough, Samuel (USPC.PRG.Atlanta)
Envoyé : jeudi 31 mai 2007 17:00
À : user-cs@ibatis.apache.org; tselke@liquidhub.com
Objet : RE: <typeAlias> support for C# Generics?


Since no one else has chimed in, I don't know if type alias supports
generics or not, I've never tried it.  It might be worth browsing the code
to see if it's immediately obvious if there's anything in there for it.



From: Tony Selke [mailto:tselke@liquidhub.com] 
Sent: Thursday, May 31, 2007 10:08 AM
To: user-cs@ibatis.apache.org
Subject: <typeAlias> support for C# Generics?

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



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, 




If we use the traditional Northwind-based example, I have the following
sqlMap alias section in the config file associated with the Category



<sqlMap namespace="Northwind.Entities.Categories" . . . >


    <typeAlias alias="Instance" type="Northwind.Entities.Categories,
Northwind.Entities" />

    <typeAlias alias="List"
type="Northwind.Entities.TList&lt;Categories&gt;, Northwind.Entities" />


. . .




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:




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?








Princeton Retirement Group, Inc - Important Terms 

This E-mail is not intended for distribution to, or use by, any person or
entity in any location where such distribution or use would be contrary to
law or regulation, or which would subject Princeton Retirement Group, Inc.
or any affiliate to any registration requirement within such location. 

This E-mail may contain privileged or confidential information or may
otherwise be protected by work product immunity or other legal rules. No
confidentiality or privilege is waived or lost by any mistransmission.
Access, copying or re-use of information by non-intended or non-authorized
recipients is prohibited. If you are not an intended recipient of this
E-mail, please notify the sender, delete it and do not read, act upon,
print, disclose, copy, retain or redistribute any portion of this E-mail. 

The transmission and content of this E-mail cannot be guaranteed to be
secure or error-free. Therefore, we cannot represent that the information in
this E-mail is complete, accurate, uncorrupted, timely or free of viruses,
and Princeton Retirement Group, Inc. cannot accept any liability for E-mails
that have been altered in the course of delivery. Princeton Retirement
Group, Inc. reserves the right to monitor, review and retain all electronic
communications, including E-mail, traveling through its networks and systems
(subject to and in accordance with local laws). If any of your details are
incorrect or if you no longer wish to receive mailings such as this by
E-mail please contact the sender by reply E-mail. 


View raw message