Print Page | Close Window

Entity Server Exception creating PredicateDescription with InList operator on nullable db properties

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2806
Printed Date: 15-Oct-2026 at 4:32pm


Topic: Entity Server Exception creating PredicateDescription with InList operator on nullable db properties
Posted By: pk55
Subject: Entity Server Exception creating PredicateDescription with InList operator on nullable db properties
Date Posted: 30-Jun-2011 at 6:50pm

I get entity server exceptions when I try to build a predicate description (either through PredicateBuilder.Make or just newing up a PredicateDescription) when the property to compare to is nullable in the db (with the exception of nullable stirngs; those always seem to work).   I've tried explicitly casting values to the nullable type (like int?), typing it as an nullable IList, etc. and nothing seems to work.

I'm using the 6.1.2.0c build.  This was from an nullable int property:
 
Exception Type: IdeaBlade.EntityModel.EntityServerException
Message: Invalid values for InList operation - not all values of type: System.Nullable`1[System.Int32]
RemoteExceptionName: System.ArgumentException
RemoteExceptionDetails: System.ArgumentException: Invalid values for InList operation - not all values of type: System.Nullable`1[System.Int32]
   at IdeaBlade.Linq.PredicateDescription.Validate()
   at IdeaBlade.Linq.PredicateDescription.Initialize(FilterOperator filterOp, Object value, Boolean ignoreCase)
   at IdeaBlade.Linq.PredicateDescription..ctor(Type instanceType, String propertyPath, FilterOperator filterOp, Object value, Boolean ignoreCase)
 
You can try it against NorthwindIB Product table.  It has some nullable smallint types:
 
var p = new PredicateDescription(typeof(Product), "UnitsInStock", FilterOperator.InList, new[] {1,2});
 
This works fine against a non-nullable db column and as I said, works on nullable strings.



Replies:
Posted By: DenisK
Date Posted: 01-Jul-2011 at 6:26pm
Thanks pk55. I've submitted another bug report for this. Just so we're on the same page, I had to modify the code as follows for it to throw the same exception.

var list = new short?[] { 1, 2 };
var p = new PredicateDescription(typeof(Product), Product.EntityPropertyNames.UnitsInStock, FilterOperator.InList, list);


Posted By: DenisK
Date Posted: 11-Jul-2011 at 4:54pm
Hi pk55;

This has just been fixed. The patch I sent you doesn't contain this fix. If you want, you can hold off on downloading that patch and I can send you a new one that includes this.



Print Page | Close Window