PredicateExpression with != null

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 26-Jan-2007 01:48:35   

With this code:

IPredicateExpression select = new PredicateExpression(CompanyFields.CompanyGroup != null);

I get the error:

The call is ambiguous between the following methods or properties: 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField.operator !=(SD.LLBLGen.Pro.ORMSupportClasses.EntityField, System.Collections.IList)' and 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField.operator !=(SD.LLBLGen.Pro.ORMSupportClasses.EntityField, SD.LLBLGen.Pro.ORMSupportClasses.Expression)'

Also, how would I add a DISTINCT clause to the predicate? I want all the CompanyFields.CompanyGroup 's which are not null and DISTINCT

ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 26-Jan-2007 02:07:56   

Solved it.

Created a Typed List based on the Company then set the allowDuplicates to false on the fill.

CompanyGroupTypedList ds = new CompanyGroupTypedList();
ISortExpression sort = new SortExpression(CompanyFields.CompanyGroup | SortOperator.Ascending);
ds.Fill(0, sort, false);
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 26-Jan-2007 09:44:04   

You should compare with DBNull.Value instead. Comparing with null indeed is ambigious, as the CLR then doesn't know which method to call.

Frans Bouma | Lead developer LLBLGen Pro