Invalid cast in generated sql using Session.Query<>

50 views
Skip to first unread message

Mario Dal Lago

unread,
Apr 22, 2012, 6:29:46 PM4/22/12
to nhibernate-...@googlegroups.com
Hello .
 
I found this issue in Nh 3.3. In Nh 3.0 works fine. 

I have this class with a char property
 
public class User
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual char Type { get; set; }
    }

running this query : 

var user = s.Query<User>().Where(x => x.Type == 'A').ToList();   

generate this sql:

select user0_.UserId as UserId0_, user0_.Name as Name0_, user0_.Type as Type0_ from [User] user0_ where cast(user0_.Type as INT)=@p0 

and throw "Conversion failed when converting the nvarchar value 'A' to data type int"

this is the mapping

 var mapper = new ModelMapper();
            mapper.Class<User>(ca =>
            {
                ca.Id(x => x.Id, map =>
                {
                    map.Column("UserId");
                    map.Generator(Generators.HighLow, gmap => gmap.Params(new { max_low = 100 }));
                });
                ca.Property(x => x.Name, map => map.Length(150));
                ca.Property(x => x.Type, map => map.Length(1));
            });

 I added an issue on jira


Thanks in advance


Mario Dal Lago
Reply all
Reply to author
Forward
0 new messages