1. Aaron D'Hooghe
  2. SnapDevelop
  3. Thursday, 2 February 2023 14:57 PM UTC

Hi,

 

I'm using a datastore to retrieve data. The RetrieveAsync methode has a parameter called arguments of type object[]. How do I best use this parameter?

For example:

I'm trying to get all rows with a column that is smaller than 1000. How do i use the RetriveAsync methode to generate this sql:

"select * from table where column <= 1000;"

And how do i use this to add multiple arguments, to generate this:

"select * from table where column1 <= 1000 and column2 > 1000;"

The documentation doesn't really specify this.

Accepted Answer
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 2 February 2023 15:42 PM UTC
  2. SnapDevelop
  3. # Permalink

Hi Aaron,

 

.NET DataStores are not used for executing queries. Their intended use is to represent a PowerBuilder DataStore. The usual use case is migrating PB DataWindows into C#, they're seldom created by hand.

If you want to execute straight queries I recommend you use the SQL Executor in the DataContext:

Here, TestModel is the C# object that will contain each one of the registers in the result.

.NET DataStore won't help you execute plain SQL queries.

 

Regards,
Francisco

Comment
There are no comments made yet.
Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Friday, 3 February 2023 01:10 AM UTC
  2. SnapDevelop
  3. # 1

Hi Aaron,


Are you asking how to pass .NET DataStore retrieve argument when affected by cancellationToken?

RetrieveAsync(object[] arguments, CancellationToken cancellationToken);

 

If yes, you can use "new object[]{value1, value2, ...}" to pass in the values of the arguments.

E.g.:
await dataStore1.RetrieveAsync(new object[] { 1000, 1000}, cancellationToken);

 

Regards, Logan

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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.