Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6157101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:43:41+00:00 2026-05-23T20:43:41+00:00

The fallowing was working with NHibernate 2.1. Now with NHibernate 3 it doesn’t. I

  • 0

The fallowing was working with NHibernate 2.1. Now with NHibernate 3 it doesn’t.
I have a Table with Column Kind, which has the fallowing Mapping:

Now, when I try do with Linq

.Where(x => x.Kind == (byte)criteria.Value)

where criteria.Value is a byte-Value, I get a InvalidCastException:(could not execute query
[ select … from ProjectType projecttyp0_ where projecttyp0_.Kind=? order by projecttyp0_.Name asc ]
Name:p1 – Value:0 ) —>

bei NHibernate.Type.ByteType.Set(IDbCommand cmd, Object value, Int32 index) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\ByteType.cs:Zeile 44.
bei NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object value, Int32 index) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\NullableType.cs:Zeile 180.
bei NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object value, Int32 index, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Type\NullableType.cs:Zeile 139.
bei NHibernate.Engine.QueryParameters.BindParameters(IDbCommand command, Int32 start, ISessionImplementor session) in d:\CSharp\NH\nhibernate\src\NHibernate\Engine\QueryParameters.cs:Zeile 638.

Does I have to change something?

Thanks for your help.

Best Regards, Thomas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:43:42+00:00Added an answer on May 23, 2026 at 8:43 pm

    I had almost the same problem: System.InvalidCastException : Specified cast is not valid.

    My POCO property was type: byte?
    My MS SQL 2005 column was type: tinyint NULL

    Every time i queried using LINQ to NHibernate on the property, System.InvalidCastException was thrown. Criteria API worked OK.

    I ended up filing a bug w/NH project

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

    Apparently, there is a bug in the MS LINQ code, casting byte to int.

    My workaround was to use the type (int?) on my POCO property, but keep TINYINT as the database type.

    In your example, criteria.Value would be an int type instead of byte. This will avoid the MS LINQ bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have working copy of war file which is working fine in windows.. Now
I'm working with nHibernate. I have make an Assembly (ex : DAL.dll), which contains
Right now I have the following code working: @UiHandler(usernameTextBox) void onUsernameTextBoxKeyPress(KeyPressEvent event) { keyPress(event);
I'm working on a java project full of Hibernate (3.3.1) mapping files that have
I have a problem that I'm working in nHibernate project that have the following
I have a rather mundane Oracle table with seven rows. Each row has different
Over the weekend I realized that an application I'm working on which uses NHibernate
I have written an application using Seam 2.2.1 & MySQL which is working. I
I have an application architecture which has following layers (or c# projects). web front
I am relatively new to using Nhibernate but basic things already are working. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.