After doing a bit more testing, this happens with MSSQL2008 as well. Since
the criteria part works fine, I will say this is an issue with the LINQ
provider for NHibernate.
With that said, are there any other LINQ providers I can use instead? I'd
rather use LINQ so I don't have to type in the field name freeform. There's
high chance of mistakes when multiple people begin working on a project.
On Wednesday, May 30, 2012 7:24:12 AM UTC-4, jlhunter wrote:
>
> The exact same. It passes it as Int32. I can get it to pass Int16 by
> making the type in the class int, but keeping the mapping type in the XML
> as short, but then I get a "Specified cast is not valid." error.
>
> On Wednesday, May 30, 2012 1:24:12 AM UTC-4, Oskar Berggren wrote:
>>
>> What happens if you use ((short)500) in the expression?
>>
>> /Oskar
>>
>>
>> 2012/5/30 jlhunter
>> > I can't figure out how to get NHibernate to map to Int16.
>> >
>> > In the class, public virtual Int16 ClientId { get; set; }
>> > In the XML, name="ClientId" column="clnt_id" type="short"
>> >
>> > It works when I use:
>> > var member = session.CreateCriteria<Member>()
>> > .Add(Restrictions.Eq("ClientId", 500))
>> > .Add(Restrictions.Eq("MemberId", 45629))
>> > .List<Member>();
>> >
>> > but not:
>> > var member = session.Query<Member>().Where(x => x.ClientId == 500 &&
>> > x.MemberId == 45629).ToList();
>> >
>> > The latter passes in Int32 for ClientId, not Int16. This causes issues
>> as
>> > the column type is smallint (it takes about 40 seconds longer when
>> passing
>> > in Int32, don't have a full grasp of what's happening).
>> >
>> > I'm not sure how to map LINQ to use Int16.
>> >
>> > Thanks
>> >
>>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/mHBkkxmodG4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.