Uploaded image for project: 'NHibernate'
  1. NHibernate
  2. NH-2789

LINQ query on byte? simple property fails on MSSQL 2005 (tinyint)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.0, 3.2.0.CR1
    • Fix Version/s: 3.3.1.GA
    • Component/s: Linq Provider
    • Labels:
      None

      Description

      Using the NH 3.1 LINQ Provider (also 3.2.0CR1), i get failing errors when including a nullable byte property in a query.

      Test
      public void LinqQueryOnNullableByteShouldWork()
      {
      using (ISession session = this.OpenSession())

      { // DomainClass entity = session.Get<DomainClass>(1); // try LINQ join on byte property var entityQueryable = from x in session.Query<DomainClass>() where x.NullableByteProperty == Convert.ToByte(16) select x; Assert.IsTrue(entityQueryable.Count() == 1); }

      }

      The generated SQL seems right, but the exception thrown is:
      System.InvalidCastException : Specified cast is not valid.

      When i try ICritera, it works (i'm using mostly LINQ provider).

      I am using MS SQL 2005 (sqlexpress and regular server). tinyint is the backing datatype.
      .NET Framework 4.0 , Visual Studio 2010.

      I will submit a failing test.

      HBM mappings (originally i use Fluent NHibernate)

      <?xml version="1.0" encoding="utf-8" ?>
      <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
      namespace="NHibernate.Test.NHSpecificTest.NH1234"
      default-access="property" auto-import="true" default-cascade="none" default-lazy="true">
      <class name="DomainClass">
      <id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="id" />
      <generator class="assigned" />
      </id>
      <property name="NullableByteProperty" type="System.Nullable`1[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="nullable_byte_property" />
      </property>
      <property name="NullableIntProperty" type="System.Nullable`1[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="nullable_Int_property" />
      </property>
      </class>
      </hibernate-mapping>

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hazzik Alexander Zaytsev
                Reporter:
                raulg Raul Nohea Goodness
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Who's Looking?