Error: At least one object must implement IComparable

Posts   
 
    
LoneWolf
User
Posts: 2
Joined: 03-Oct-2006
# Posted on: 03-Oct-2006 23:11:13   

Using llblgen v2 - SelfServicing - .net 2.0 and VS2005 In the code below MemberFields.EndDate is null in the database. Running the below code generates the error below.

Is there a reason that this error is generated or am I using this wrong.



        PredicateExpression filter = new PredicateExpression();
        filter.Add(MemberFields.EndDate > DateTime.Now);

        EntityView<MemberEntity> MyMembersView = Member.MyMembers.DefaultView;
        MyMembersView.Filter = filter;

        return (MemberCollection)MyMembersView.ToEntityCollection();


**At least one object must implement IComparable. **

[ArgumentException: At least one object must implement IComparable.] System.Collections.Comparer.Compare(Object a, Object b) +156 SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.InterpretPredicate(IEntityCore entity) +229 SD.LLBLGen.Pro.ORMSupportClasses.Predicate.SD.LLBLGen.Pro.ORMSupportClasses.IPredicateInterpret.Interpret( IEntityCore entity) +4 SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.InterpretPredicate(IEntityCore entity) +158 SD.LLBLGen.Pro.ORMSupportClasses.Predicate.SD.LLBLGen.Pro.ORMSupportClasses.IPredicateInterpret.Interpret( IEntityCore entity) +4 SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore1.FindMatches(IPredicate filter) +174 SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase1.SetFilter(IPredicate filter) +28 SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.set_Filter(IPredicate value) +9

The below works but I want to filter on the collection in memory.



        PredicateExpression filter = new PredicateExpression();
        filter.Add(MemberFields.EndDate > DateTime.Now);

        return Member.GetMultiMyMembers(false, filter);


bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 04-Oct-2006 03:35:16   

When I run the code with 0 results for the filter I get the error that the index is out of range. Otherwise I cannot get an error when executing this code. Can you post more of the code that is used for this query and which line exactly throws the exception.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 04-Oct-2006 10:37:32   

I think it's a bug. I'll do some more testing, but what I think happens is that the field value is reported as DBNull.Value by the interpreter, and because it's compared with null, it's allowed as a value, and then ends up in the comparer, causing this issue.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 04-Oct-2006 11:30:13   

Reproduced.

Fixed in next build.

Frans Bouma | Lead developer LLBLGen Pro
LoneWolf
User
Posts: 2
Joined: 03-Oct-2006
# Posted on: 04-Oct-2006 22:30:17   

Thanks for the quick reply. Great app and keep up the good work.

John