ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Smiley <ssmiley...@yahoo.com>
Subject Custom Type Handler for Enumeration Types
Date Thu, 28 Jul 2005 19:30:09 GMT
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

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

Thanks in advance, 


Below are the relevant code pieces:

sqlmap.config file:
    <typeAlias alias="UserTypeHandler"
Data" />
    <typeHandler type="UserTypeEnumeration"
dbType="VarChar" callback="UserTypeHandler" />
UserAccount.xml file:
		<typeAlias alias="UserBase"
type="Xhibitnet.Gmri.MysteryWeb.Data.UserBase, Data"
		<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" />
UserTypeEnumHandlerCallback class:
	public class UserTypeEnumHandlerCallback :
		#region Declarations
		private static log4net.ILog _Logger =
		#region Constructors/Destructor
		public UserTypeEnumHandlerCallback()

		#region ITypeHandlerCallback Members

		public object ValueOf(string s)
			return s;

		public object GetResult(IResultGetter getter)
			string UserTypeText = getter.Value.ToString();

			UserAccountType UserType =

			return UserType;

		public void SetParameter(IParameterSetter setter,
object parameter)
			setter.Value = parameter.ToString();


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

View raw message