Sorter

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 02-Jun-2012 11:43:12   

LLBLGEN 3.5 SQL 2000 LLBLGEN runtime framework C# windows application

 dgridsearchtitle.ReadOnly = true;
            var Title = new TitleCollection();
            IPredicateExpression Filter = new PredicateExpression();
            Filter.Add (new FieldCompareValuePredicate(TitleFields.Flag, ComparisonOperator.Equal, Flag.validflag));
            Title.GetMulti(null);
            dgridsearchtitle.DataSource = Title;

can you please help on how to add sorter in the above code

shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 02-Jun-2012 13:36:08   

shekar wrote:

LLBLGEN 3.5 SQL 2000 LLBLGEN runtime framework C# windows application

 dgridsearchtitle.ReadOnly = true;
            var Title = new TitleCollection();
            IPredicateExpression Filter = new PredicateExpression();
            Filter.Add (new FieldCompareValuePredicate(TitleFields.Flag, ComparisonOperator.Equal, Flag.validflag));
            Title.GetMulti(null);
            dgridsearchtitle.DataSource = Title;

can you please help on how to add sorter in the above code

I think I can manage like this simple_smile

T

itleCollection Title = new TitleCollection();
            ISortExpression sorter = new SortExpression(TitleFields.Description | SortOperator.Ascending);
            IPredicateExpression filter = new PredicateExpression(TitleFields.Flag == Flag.validflag);
            Title.GetMulti(null);
            EntityView<TitleEntity> Titleview = new EntityView<TitleEntity>(Title);
            Titleview.Sorter = sorter;
            dgridsearchtitle.DataSource = Titleview;

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jun-2012 22:52:02   

Yes, in that case you are sorting in-memory, that is you fetch the collection from db un-sorted and then you created a sorted version of the EntityView.

You also can sort on DB directly, so a "ORDER BY" clause is used in the generated SQL:

TitleCollection Title = new TitleCollection();
ISortExpression sorter = new SortExpression(TitleFields.Description | SortOperator.Ascending);
IPredicateExpression filter = new PredicateExpression(TitleFields.Flag == Flag.validflag);
Title.GetMulti(null, 0, sorter);

dgridsearchtitle.DataSource = Title;

This is explained in the docs: Sorting, SelfServicing

David Elizondo | LLBLGen Support Team