1. Roland Smith
  2. PowerBuilder
  3. Friday, 7 December 2018 21:32 PM UTC

I was thinking about the new feature where you can generate C# code from a DataWindow object.

Will there also be an NVO to C# generator? PB 12.5 that I use now has a .Net Assembly wizard but it doesn't really allow for seeing the code.

 

Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Saturday, 8 December 2018 06:59 AM UTC
  2. PowerBuilder
  3. # 1

Elaborating on what Chris said, while there will not be an automatic PowerScript-to-C# converter, the fact that our C# framework includes the DataStore and any embedded SQL can be basically copy n' paste into the SQLExecutor so it's not like you have to rethink and rewrite all your code... it is basically a "port" effort

Example PowerScript code:

public function datastore of_retrieve (date ad_start, date ad_end, decimal adec_amt);
Datastore lds
lds = Create Datastore
lds.dataobject = "d_order_customer"
lds.SetTransObject(SQLCA)
lds.Retrieve(ad_start, ad_end, adec_amt)
Return lds
end function

Example C# code:

public IDataStore GetOrderCustomerInfo(DateTime startDate, DateTime endDate, decimal amount)
{
    IDataStore dataStore = new DataStore("d_order_customer", _context);
    dataStore.Retrieve(startDate, endDate, amount);
    return dataStore;
}

Also, just to clarify, the DataWindow data object is automatically migrated to a C# data model... we provide a tool to do this.  Here is example of what the automatically generated C# data model looks like for this:

public class OrderCustomer
{
    [SqlColumn("Title")]
    public string Person_Title { get; set; }
 
    [SqlColumn("FirstName")]
    public string Person_Firstname { get; set; }
 
    [SqlColumn("MiddleName")]
    public string Person_Middlename { get; set; }
 
    [SqlColumn("LastName")]
    public string Person_Lastname { get; set; }
 
    [SqlColumn("ModifiedDate")]
    public DateTime? Customer_Modifieddate { get; set; }
 
    [SqlColumn(tableAlias: "c", column: "CustomerID")]
    public int Customer_Customerid { get; set; }
 
    [SqlCompute(alias: "SumAmt", expression: "Sum(o.SubTotal )")]
    public decimal? Sumamt { get; set; }
 
    [SqlCompute(alias: "AvgAmt", expression: "Avg(o.SubTotal )")]
    public decimal? Avgamt { get; set; }
}
Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 7 December 2018 21:54 PM UTC
  2. PowerBuilder
  3. # 2

Hi Roland;

  In essence - I think that you might be asking ... Is there going to be a PowerScript to C# converter built into PB2018.

Answer:  NO

Regards ... Chris

Comment
  1. Roland Smith
  2. Friday, 7 December 2018 21:56 PM UTC
Assuming I knew how to code C#, I could add methods to the generated Assembly and do it manually?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Saturday, 8 December 2018 01:08 AM UTC
Yes, once the base C# Assembly is built by the IDE ... Then Absolutely, you can extend it's functionality by adding your own C# code.
  1. Helpful
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.