Mapping enum with fluent nhibernate
Posted
by Puneet
on Stack Overflow
See other posts from Stack Overflow
or by Puneet
Published on 2009-09-27T07:42:58Z
Indexed on
2010/03/24
22:03 UTC
Read the original article
Hit count: 277
I am following the http://wiki.fluentnhibernate.org/Getting%5Fstarted tutorial to create my first NHibernate project with Fluent NHibernate
I have 2 tables
1) Account with fields
Id
AccountHolderName
AccountTypeId
2) AccountType with fields
Id
AccountTypeName
Right now the account types can be Savings or Current So the table AccountTypes stores 2 rows 1 - Savings 2 - Current
For AccoutType table I have defined enum
public enum AccountType {
Savings=1,
Current=2
}
For Account table I define the entity class
public class Account {
public virtual int Id {get; private set;}
public virtual string AccountHolderName {get; set;}
public virtual string AccountType {get; set;}
}
The fluent nhibernate mappings are:
public AgencyMap() {
Id(o => o.Id);
Map(o => o.AccountHolderName);
Map(o => o.AccountType);
}
When I try to run the solution, it gives an exception - InnerException = {"(XmlDocument)(2,4): XML validation error: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'ur...
I guess that is because I have not speciofied any mapping for AccountType.
The questions are:
- How can I use AccountType enum instead of a AccountType class?
- Maybe I am going on wrong track. Is there a better way to do this?
Thanks!
© Stack Overflow or respective owner