Bug with sorting and predicateExpression?

Posts   
 
    
Dominique
User
Posts: 22
Joined: 13-Sep-2005
# Posted on: 29-Sep-2005 22:43:01   

Hello,

If i execute the following code, the collection I get, includes records where Passengerremoved = 1 and it shouldn't.

IPredicateExpression predicatepassengers = new PredicateExpression(); predicatepassengers.Add(PredicateFactory.CompareValue(TravelAgent.Dal.PassengersFieldIndex.Passengerremoved, ComparisonOperator.Equal, "0")); fileEntry.Passengers.SupportsSorting = true; fileEntry.Passengers.Sort((int)TravelAgent.Dal.PassengersFieldIndex.Passengername, ListSortDirection.Ascending); gridPassengers.DataSource = fileEntry.GetMultiPassengers(false, predicatepassengers);

When I comment out the 2 lines below, it is correct and the records with value 1 in passengerremoved are not in the list of records.

fileEntry.Passengers.SupportsSorting = true; fileEntry.Passengers.Sort((int)TravelAgent.Dal.PassengersFieldIndex.Passengername, ListSortDirection.Ascending);

Any suggestions? frowning

MacDennis avatar
MacDennis
User
Posts: 50
Joined: 03-May-2005
# Posted on: 29-Sep-2005 23:45:08   

I'm not sure why the filter doesn't work but the .Sort() function sorts in-memory collections. Looking at your code, the collection is fetched after the Sort() call.

Place the Sort() call after the GetMultiPassengers() call and see what happens.

See also: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=1581 And: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=432

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 30-Sep-2005 16:19:29   

Please pass "true" instead of false as the first parameter in the GetMulti.... function.

Refer to the LLBLGen Pro documentation, and read the following section: "Load on demand/Lazy loading" under "Using the generated code -> SelfServicing -> Using the entity classes"

Good Luck