1. Roland Smith
  2. SnapDevelop
  3. Friday, 25 June 2021 18:42 PM UTC

I'm doing the PB to C# tutorial:


So first I have to manually create several files (controllers, services, interfaces) which the tutorial kindly gives you code to copy. Then when I get to actually converting the PB code, it says to click into each function individually and to generate C# code and then manually copy and paste it into one of the files created earlier.

There is a translate option at the nvo level but even that appears to require copy paste. The tutorial doesn't mention that feature. With all these manual steps, what is the point of using the tool? I thought that when you translate an nvo that it would write all the C# generated code to the various files itself. How is this better than a C# expert with prior PB experience re-writing the entire thing manually?

There isn't even any help built into the IDE, the Help menu only has About.


Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Saturday, 26 June 2021 17:07 PM UTC
  2. SnapDevelop
  3. # 1

Hi Roland,

Having to copy n' paste manually is least of your worries... migrating PowerBuilder code to C# with the PowerScript Migrator is going to require significant work: 1) partitioning your business logic, 2) dealing with unsupported features, 3) adjusting for differences between C# and PowerScript, 4) performance tuning the code, 5) creating a new UI by hand (no automatic conversion of UI), etc.

With that said, even if you think very little of your PowerScript can be salvaged (or at least not worthwhile to salvage), simply migrating your DataWindow objects and embedded SQL is going to shave of lots of time and money. In our experience, almost 100% of DataWindow objects and embedded SQL can be migrated automatically to C# using the PowerScript Migrator.

You might think that just migrating these two things is a small % of your whole app, but because rewrite projects are so long and time consuming that even small % reduction is huge absolute savings!  Many of our end customers tell us a rewrite costs anywhere between $1-5 million per app and ISVs tell us a rewrite costs between $5-20 million per app.

Aside from cost, the other thing you are not considering is risk... most of these rewrites have failed.  Simply using the .NET DataStore object and not even converting any existing code assets still reduces the risk exponentially. Because it makes C# programing PowerBuilder-like in concepts, the PB team is experienced at rewriting the app compared to trying to code in C# against a foreign framework, such as Entity Framework, Dapper, or ADO.NET.

Just compare these two different ways of coding C# and I guess you would prefer prefer .NET DataStore over Entity Framework.

C# Dev with .NET DataStore

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

C# Dev with Entity Framework 

public IEnumerable<D_Order_Customer> GetOrderCustomerInfo(DateTime startDate, DateTime endDate, decimal amount)
    var query = from c in _context.Set<EFCore_Customer>()
                join p in _context.Set<EFCore_Person>() 
                    on c.PersonId equals p.Businessentityid
                join s in _context.Set<EFCore_SalesOrderHeader>()
                    on c.CustomerId equals s.CustomerId
                where s.OrderDate >= startDate &&
                      s.OrderDate <= endDate
                group s.SubTotal by new
                into g
                let avg = g.Average()
                where avg > amount
                orderby avg
                select new D_Order_Customer
                    Person_Title = g.Key.Title,
                    Person_Firstname = g.Key.Firstname,
                    Person_Middlename = g.Key.Middlename,
                    Person_Lastname = g.Key.Lastname,
                    Customer_Modifieddate = g.Key.ModifiedDate,
                    Customer_Customerid = g.Key.CustomerId,
                    Sumamt = g.Sum(),
                    Avgamt = avg
    return query.ToList();

Best regards,

  1. Roland Smith
  2. Monday, 28 June 2021 13:25 PM UTC
Thanks for the info. We have PowerBuilder and web developers. The PB app is about 20 years old and the web app 7-8 years old. It is written in C# with nHibernate. We recently brought on some consultants to speed up the process of writing new web pages to replace PB windows. Management asked me to look at whether SnapDevelop could help with some of the business logic.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Monday, 28 June 2021 15:31 PM UTC
nHibernate is quite similar to Entity Framework... it's going to be way more coding and more complex than .NET DataStore. Even if you are writing new pages, I think it would be prudent one of the C# developers carefully evaluate .NET DataStore. The added benefit besides productivity savings, is that .NET DataStore can return data in both plain JSON and DataWindow JSON format so you can easily share business logic between your PB client app and Web apps instead of duplicating code.
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Friday, 25 June 2021 20:13 PM UTC
  2. SnapDevelop
  3. # 2

Hi Roland,

The "translate and copy-paste" approach is not the only one you can follow. You can also generate a C# class from the NVO by clicking on the Save As button on the editor (provided you opened the NVO by clicking Translate selected item on the Solution Explorer's context menu). This will prompt you for a location on which to create the C# file.

This will, nonetheless, require some manual adjustments depending on your particular use case, like prepending using PowerScript.Bridge; at the beginning of the file, removing the create and destroy functions, or introducing a DataContext object into the class. This will be specific to your circumstances. It would be also recommended to change the class to conform to C# standards (Camel-case, no underscores)

Hope this helps!


There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 25 June 2021 18:46 PM UTC
  2. SnapDevelop
  3. # 3

I tried to do the functions individually but the 'Original PB code' in the tutorial is different from the actual code.

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.