Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Invalid cast in generated sql using Session.Query<>
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mario Dal Lago  
View profile  
 More options Apr 22 2012, 6:29 pm
From: Mario Dal Lago <the4po...@yahoo.com.ar>
Date: Sun, 22 Apr 2012 15:29:46 -0700 (PDT)
Local: Sun, Apr 22 2012 6:29 pm
Subject: Invalid cast in generated sql using Session.Query<>

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

https://nhibernate.jira.com/browse/NH-3124 

Thanks in advance

Mario Dal Lago


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »