SybaseASE15 Int16 LINQ

31 views
Skip to first unread message

jlhunter

unread,
May 29, 2012, 7:36:03 PM5/29/12
to nhu...@googlegroups.com
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

Oskar Berggren

unread,
May 30, 2012, 1:24:12 AM5/30/12
to nhu...@googlegroups.com
What happens if you use ((short)500) in the expression?

/Oskar


2012/5/30 jlhunter <jlhu...@gmail.com>:
> --
> 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/-/BItFX6A56RsJ.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to
> nhusers+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.

jlhunter

unread,
May 30, 2012, 7:13:57 AM5/30/12
to nhu...@googlegroups.com
It acts the same. The only time I can make it go to Int16 is when I set the class as int (Int32) and the mapping xml as short - but then I get an 'Specified cast is not valid' error. I gave up tracing that issue down yesterday.

I'm considering just faking out NHibernate and making my own 'custom class' that's really just an Int16...

I really think it's a Sybase mapping issue- could it be that I'm using ASE12.5 but the 15 driver? 12.5 didn't come with my version of NHibernate
> nhusers+unsubscribe@googlegroups.com.

jlhunter

unread,
May 30, 2012, 7:24:12 AM5/30/12
to nhu...@googlegroups.com
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

jlhunter

unread,
May 30, 2012, 1:15:56 PM5/30/12
to nhu...@googlegroups.com
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.

Alexander I. Zaytsev

unread,
May 30, 2012, 1:35:20 PM5/30/12
to nhu...@googlegroups.com
It is the same issue as in  https://nhibernate.jira.com/browse/NH-3124 but with short to int conversation. 

2012/5/30 jlhunter <jlhu...@gmail.com>
--
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.

jlhunter

unread,
May 30, 2012, 2:56:03 PM5/30/12
to nhu...@googlegroups.com
Thanks a lot Alexander. I used .Equals, like the article said (even though it says the issue is resolved, it's not) and it worked fine.

Thanks again.


On Wednesday, May 30, 2012 1:35:20 PM UTC-4, Alexander I. Zaytsev wrote:
It is the same issue as in  https://nhibernate.jira.com/browse/NH-3124 but with short to int conversation. 

2012/5/30 jlhunter
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.
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.
2012/5/30 jlhunter
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.
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.

Alexander I. Zaytsev

unread,
May 30, 2012, 3:47:07 PM5/30/12
to nhu...@googlegroups.com
Issue is resolved only for char to int conversion. I will rise a new issue for that.

2012/5/31 jlhunter <jlhu...@gmail.com>
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/7bRqlWw8FAQJ.

To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages