tags:

views:

151

answers:

1

Hi,

Using SQL Server 2005 I have a table that contains a bit field. When the table is viewed, the console automatically translates this to true/false.

So I'm trying to query this with nHibernate to match all records for which this field is "true", like this:

    Dim results As ArrayList = session.CreateCriteria(Of DataTransferObjects.Product) _
        .CreateAlias("Skus", "sku") _
        .Add(Expression.Eq("sku.IsUnlimitedStock", True)) _
    .List()

Which throws the error Type mismatch in NHibernate.Criterion.SimpleExpression: sku.IsUnlimitedStock expected type System.Boolean, actual type System.String

Now I've tried various things here: replacing the True statement with 0, "True" and ensuring that True is actually a boolean by casting it, but I always get the same error.

What value is nHibernate expecting?

A: 

Ignore this. I just got the same error message twice in a row but I failed to notice the second one was coming from a different line of code, and the cause of that was rather more obvious ....

Matt Thrower
If the question is not valid, it should be deleted.
Lachlan Roche