Oxygene with WPF MVVM EntityFramework and DevExpress

(Bob Russell) #1

Having spent the last months/year! learning (and finding it tough!) I need to try a real world project.

I have the DevExpress WPF suite which includes a number of very useful functions that simplify the initial creation of the some of the DataSource and EF/MVVM “stuff” used when first creating the project. The problem, of course, is that all these assume a C# project. I’m finding it very difficult to see how to combine this with an Oxygene project. Also, all the examples/tutorials in DevExpress assume a C# project. I love the “Ex-Delphi Pascal” syntax, and wouldn’t really like to abandon this and go to pure C#.

My question therefore is, Is there any body out there who was in a similar situation who could advise me - either in what direction to go, or any resources that might be useful.

Any thoughts welcome

Bob Russell

(Glenn Laderer) #2

Hi Bob, Not an expert but I have been working with MVVM principals to a mid range degree and also with EF. No experience with DevExpress. If you have questions I would be willing to try and answer them if you want. Perhaps we can expand each others knowledge in the process. Let me know if you are interested.

(Bob Russell) #3

Hi Glenn. Many thanks for your reply. I’d certainly be interested in sharing experiences. Do you use Oxygene as your base language?
As a many years self taught Delphi person, my approach was certainly not text book! The projects were usually small, typically under 30 users, and the underlying database fairly simple, and usually MS Access.
My answer to the question of separating UI and UI functionality from the business logic and data was basically not to bother too much! Although I did use separate .pas files for different purposes:

Forms - with as little code in other than events calling functionality in another .pas file

Business Logic files, but still making direct reference to UI controls

Data, making ADO connections, general control.

Because data performance was not normally an issue I used to use a separate ADOQuery defined (and freed) in each bit of logic.

To populate, say a grid, from the database, I’d create a dynamic array to act as half-way house between the ADO Data Table, and the Grid, then codewise get the raw data from the Table, using the Query, then manipulate the that data to build the array rows. Then as a last step, read the array and populate the grid. User actions like filtering and ordering would be done using code to rebuild the array, then re-populate the grid.

Probably very crude, but for smaller data loads, it gave me complete control of what could be very dynamic displays of data.

Going from that to WPF/MVVM/EF where such a lot of stuff is defined at design time has left me struggling. Also the sophistication of UI controls today (such as in the DevExpress Grid and Scheduler controls) makes it impractical I think to use my “old” approach.

I’m hoping that once I “get it”, I can perhaps blend some of my older knowledge with the new possibilities, but so far it has been a struggle.

Do you have a very very simple WPF/MVVM/EF project that you could share? Then perhaps we can talk through how you set it up. I have seen some examples in the RO documentation, but they seem to skip over bits without going “behind the scenes”. DevExpress have lots fo great examples, but they use their tools to set up the project, and that of course uses straight C#. I’m getting more familiar with C# but it’s an additional barrier, and I’m not sure how much one can mix C# and Oxygene in the same project.

So, I hope I’ve not put you off too much! Any feedback or comments would be very welcome.

Regards Bob Russell

(Glenn Laderer) #4

I myself used Delphi from 1995-2010. Not any large scale applications but I came up with an enhanced component for helping deal with ClientDataSets and ADO interaction to handle Identity updates and with Master -> Child dependencies. One of the things that might make Databinding easier to absorb (if you have not already) is to think of the View as your form, your viewmodel as a DataModule. Not exactly the same but a good general analogy. I do use Oxygene now ever since the Delphi Prism days. I have not written any large scale applications but I am working on something that once I am done should help enable faster application development utilizing EF and MVVM. I might have a simple app to share. I am still learning. In Delphi I would have my data source as ADO Stored Procedures and the create ClientDatasets that referenced those ADO DataSets and the buind the UI to the Client Data Sets from the Data Module. The ADO Data sets were in the same data module but did not have to be. The business logic if any needed would be in the Data Module and any thing UI related would go in the form logic file. Contact me at personal email for the app I can share, my email is gladerer@roadrunner.com. I do not want to post it to the whole world, as it is a functioning work app. I really do not want to sanitize it too much.

(Bob Russell) #5

Glenn. Thanks for this. Interesting how you evolved a methodology with Delphi. I was going to suggest that we continue by email, so will contact you.