Fixed
Details
Assignee
Alex Zaytsev
Alex ZaytsevReporter
Raul Nohea Goodness
Raul Nohea GoodnessComponents
Fix versions
Priority
Who's Looking?
Open Who's Looking?
Created July 11, 2011 at 7:06 PM
Updated August 2, 2012 at 8:54 AM
Resolved May 23, 2012 at 7:54 PM

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>