Have you an alias for UserTypeEnumeration ?

On 7/28/05, Gilles Bayon <[EMAIL PROTECTED]> wrote:
Why don't you don't store the value of the enum in db, ibatis support this natively.
See nunit tests for examples.
 
-Gilles

 
On 7/28/05, Shawn Smiley <[EMAIL PROTECTED] > wrote:
Hi all,

I just started using iBatis on a new C# project and
have run into my first issue.

I have a UserAccounts table which conveniently maps to
a UserAccount object.  One of the properties of this
object is an enumeration of UserTypes which are stored
in the database as the text name of the enum value
(i.e. UserType.Student is stored in the database as
"Student").

So far I've tried to implement a custom Type Handler
for this field/property based on the Guid example in
the documentation.  Unfortunately I keep getting the
error message "System.TypeLoadException : Could ot
load type : UserTypeEnumeration".

Can anyone offer some suggestions on what I'm doing
wrong?

Thanks in advance,

Shawn.

Below are the relevant code pieces:

============================
sqlmap.config file:
============================
<alias>
   <typeAlias alias="UserTypeHandler"
type="Xhibitnet.Gmri.MysteryWeb.Data.TypeHandlers.UserTypeEnumHandlerCallback ,
Data" />
</alias>
<typeHandlers>
   <typeHandler type="UserTypeEnumeration"
dbType="VarChar" callback="UserTypeHandler" />
</typeHandlers>
============================
UserAccount.xml file:
============================
<alias>
               <typeAlias alias="UserBase"
type="Xhibitnet.Gmri.MysteryWeb.Data.UserBase, Data"
/>
       </alias>

       <resultMaps>
               <resultMap id="SelectResult" class="UserBase">
                       <result property="Active" column="Active" />
                       <result property="Deleted" column="Deleted" />
                       <result property="EncryptedPassword"
column="Password" />
                       <result property="FirstName" column="FirstName" />
                       <result property="LastName" column="LastName" />
                       <result property="MustChangePassword"
column="MustChangePassword" />
                       <result property="UserId" column="UserID" />
                       <result property="Username" column="Username" />
                       <result property="UserType" column="UserType" />
               </resultMap>
       </resultMaps>
============================
UserTypeEnumHandlerCallback class:
============================
       public class UserTypeEnumHandlerCallback :
ITypeHandlerCallback
       {
               #region Declarations
               private static log4net.ILog _Logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
               #endregion

               #region Constructors/Destructor
               public UserTypeEnumHandlerCallback()
               {
               }
               #endregion

               #region ITypeHandlerCallback Members

               public object ValueOf(string s)
               {
                       return s;
               }

               [CLSCompliant(false)]
               public object GetResult(IResultGetter getter)
               {
                       string UserTypeText = getter.Value.ToString();

                       UserAccountType UserType =
(UserAccountType)GmriUtility.StringToEnum(typeof(UserAccountType),
UserTypeText);

                       return UserType;
               }

               [CLSCompliant(false)]
               public void SetParameter(IParameterSetter setter,
object parameter)
               {
                       setter.Value = parameter.ToString();
               }

               #endregion
       }


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Reply via email to