views:

102

answers:

1

This is a bug? Using NHibernate.Expression.Example.Create(userExample) if my class use Int32 on property 'Type' all works fine.

public class User:Person
{

    public virtual String NickName { get; set; }
    public virtual String Password { get; set; }
    public virtual Int32 Type { get; set; }

    public enum UserType
    { 
        Normal = 0,
        Broker = 1
    }

}

but using the enum the critéria return null:

public class User:Person
{
public virtual String NickName { get; set; }
public virtual String Password { get; set; }
public virtual UserType Type { get; set; }

public enum UserType
{ 
    Normal = 0,
    Broker = 1
}

}

In console, query is showing 'Broker', this is the problem, i think that is a error of NHibernate, any sugestions?

A: 

Without seeing your query, you can try this expression. I assume your storing the enum as an int your db.

 Expression.Eq("Type",(int) userType);
mxmissile
Yes is a int field. When i save the user trought a NHibernate then implict convert UserType to int but using ByExample method..XD!!This is the unique way:Expression.Eq("Type",(int) userType);??????
CrazyJoe