1. Ramón San Félix Ramón
  2. SnapDevelop
  3. Saturday, 26 September 2020 09:45 AM UTC

In my PowerBuilder applications I order the datawindow with various parameters as in the following example ...

dw_1.SetSort("param1 a, param2 a, param3 a")

dw_1.Sort()

 

In SnapDevelop I see Sort Method, but I don't  know how to order multiples parameters....

var dw_1 =  new DataStore<mymodel>(_dataContext);

dw_1.Sort( a => a.Param1 );

How can I add parem2 and param3 ?

Best Regards.

Accepted Answer
Ramón San Félix Ramón Accepted Answer Pending Moderation
  1. Monday, 28 September 2020 14:40 PM UTC
  2. SnapDevelop
  3. # Permalink

 

I have found the answer to my question ...

Using the SortBy, ThenBy and Sort methods like this:

 

var dw_1 = new DataStore<mymodel>(_dataContext);

dw_1.SortBy( a => a.Param1 ).ThenBy(b => b.Param2).ThenBy(c => c.Param3);

dw_1.Sort();

 

I don't know if this will be the most elegant way, but it seems to work ...

Best Regards.

 

Comment
  1. Armeen Mazda @Appeon
  2. Monday, 28 September 2020 16:11 PM UTC
Thanks for sharing the solution!
  1. Helpful
There are no comments made yet.
Ramón San Félix Ramón Accepted Answer Pending Moderation
  1. Sunday, 27 September 2020 08:43 AM UTC
  2. SnapDevelop
  3. # 1

I have already tried that before asking.


The code converter gives me the solution using the DataStore class and the SetSort and Sort methods, which are almost identical to PowerBuilder.


My question is to learn how to properly use the DataStore <TModel> class which is supposed to be more friendly to CSharp programmers...

Unfortunately the official help provides few code examples and always very simple, compared to the applications that we already have written in PowerBuilder ...

Comment
  1. Miguel Leeuwe
  2. Sunday, 27 September 2020 10:51 AM UTC
I thought this was your initial question: "How can I add parem2 and param3 ?"
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Sunday, 27 September 2020 15:19 PM UTC
Oh I see, yes, you are correct. Please look at my revised answer that has links to the docs.
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Saturday, 26 September 2020 14:42 PM UTC
  2. SnapDevelop
  3. # 2

A efficient way to learn is code in PowerScript and then use the PowerScript Migrator to see what the corresponding C# code looks like.  PowerScript Migrator included in PB CloudPro version 2019 R2 and newer.

If you want to use the DataStore with the generic APIs so that it inherits from an IList, then you would not be able to use the PowerScript Migrator.  Instead, please refer to the IDataStore<T> section of the docs that has information about using Sort method for generic API and also code example.

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Saturday, 26 September 2020 11:44 AM UTC
  2. SnapDevelop
  3. # 3

Haven't used it myself yet, but could this be of help?

https://docs.appeon.com/dwconverter2019r2/api_reference/DWNet.Data/DataStore/DataStore/DataStore.html

Search on the page on "setsort" and "sort".

 

What I'm not sure of is whether this applies to The snapobjects' datastore or if it's something else.

I don't find the organisation of the reference very clear to be honest.

regards

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.