My application has the following database structure:
Transactions:
- TransactionID (PK, Identity, Int)
- TypeID (FK, Int)
- Amount (Decimal)
TransactionTypes:
- TypeID (PK, Identity, Int)
- Type (NVarChar)
They are defined in my application as:
public class Transaction
{
    public virtual int TransactionID { get; set; }
    public virtual TransactionTypes Type { get; set; }
    public virtual decimal Amount { get; set; }
}
public enum TransactionTypes
{
    Event = 1,
    Product = 2
}
With the following mapping:
public class TransactionMap : ClassMap<Transaction>
{
    public TransactionMap()
    {
        Table("Transactions");
        Id(x => x.TransactionID);
        Map(x => x.Type, "TypeID").CustomType<int>();
        Map(x => x.Amount);
    }
}
Everything works fine apart from querying. When i try doing:
session.Linq<Transaction>().Where(t => t.Type == TransactionTypes.Event).ToList();
It throws the error "Type mismatch in NHibernate.Criterion.SimpleExpression: Type expected type System.Int32, actual type Entities.TransactionTypes".
I'd appreciate it if someone could show me the correct way to map this. Thanks
 
     
    