1. FIlippo Donà
  2. SnapDevelop
  3. Wednesday, 22 March 2023 10:55 AM UTC

Hello, I have implemented an ASP .NET Core Web API project that uses datawindows created in PowerBuilder to read data.
Following the tutorial I was able to easily create an API which, after converting the datawindow into a C# Model, reads the data from the database.

Now I'm having problems with the computed fields of a datawindow. In the C# Model the computed fields are present and report the expression for the evaluation however when the API is called these fields are not valued and remain null.

This is the PowerBuilder datawindow with computed fields and their relative expressions.

This is the C# Model auto generated

...and this is the API response

I noticed that in the C# Model in the computed fields there are these two notations: JsonIgnore and IgnoreDataMember. I thought they might be why the computed fields weren't returned in the API response but even removing them the result doesn't change.

Can someone with more SnapDevelop experience help me out?

Environment:
SnapDevelop 2022
TargetFramework .NET 6
PowerBuilder 2022

Thank you all

FIlippo Donà Accepted Answer Pending Moderation
  1. Monday, 27 March 2023 07:09 AM UTC
  2. SnapDevelop
  3. # 1

Thank you Logan for the explanation and the time you have dedicated to me. Now everything is much clearer, the topic can be considered resolved.

Comment
There are no comments made yet.
FIlippo Donà Accepted Answer Pending Moderation
  1. Thursday, 23 March 2023 09:54 AM UTC
  2. SnapDevelop
  3. # 2

Thank you Logan for taking the time to answer my question.

So if I understand correctly, if I want to calculate all the Computed Fields, I must first retrieve the datastore and then cycle the datastore and call the GetModel method for each row, right? In this case isn't there a more performant way to compute the Computed Fields than having to loop through all the recordsets by hand?

How does the Cumputed Column work? I didn't find it in my PowerBuilder 2022 environment.

Thank you.

Comment
  1. Logan Liu @Appeon
  2. Monday, 27 March 2023 02:28 AM UTC
Hi Filippo,

1) "So If I understand correctly, if I want to calculate all the Computed Fields, I must first retrieve the datastore and then cycle the datastore and call the GetModel method for each row, right?"

Correct.



2) "In this case isn't there a more performant way to compute the Computed Fields than having to loop through all the recordsets by hand?

You can also consider extending a new method on .NET DataStore by yourself.



Please notice that all PB native DataWindow Computed Fields are running locally on the client side, some functions even depend on the DataWindow UI elements. So I suggested you try not to use PB DataWindow Expression in your Web API unless necessary.



3) "How does the Cumputed Column work?"

In the SQL Select painter, you can define computed columns when defining the SELECT statement that will be used to retrieve data into the DataWindow object. Refer to the PowerBuilder IDE Users Guide (https://docs.appeon.com/pb2022/pbug/ch06s03s01.html#d0e39213).

Regards, Logan

  1. Helpful
There are no comments made yet.
Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Thursday, 23 March 2023 09:21 AM UTC
  2. SnapDevelop
  3. # 3

Hi Filippo,

Please notice DwCompute (converted from PB DataWindow Computed Field) can not be computed automatically for performance consideration. 

If you import this JSON to the PB DataWindow, it will show the value of the Computed Field.

If you need to use the value of the Computed Field in the Web API project, you can try the GetModel method to compute a row: https://docs.appeon.com/net_datastore/4.x/api_reference/DWNet.Data/DataStore/IDataStore/Method/GetModel2.html

Alternatively, you can change Computed Field to Computed Column in PB DataWindow.

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.