This Entity stuff just works ! Great with LINQ ...
Posted: Thu Jan 19, 2017 12:43 pm
Hi guys,
Well, around my time making picture frames (recently) I have managed to move-forward the demo app for Cologne, on LINQ and Entity Framework, with WPF/XAML and data binding. The results of the development are even amazing to me - he who designed it !
Entity Framework 6 takes so much of the mundane 'boring' bits out of database work that it almost makes me smile.
First of all lets see the finished input screen for a user to create and save a new Order for a selected customer :-
Note that all the screen data is 'data bound' as public properties in the ViewModel. The zero entries in the cells of the DataGrid show that the EF6 system has not yet saved the new order, as it will eventually allocate IDs when it does.
We have made the code as clean as it should be for an MVVM approach, and the code behind looks like this :-
For anyone who has had to use ADO.NET in the past years, and do all the database work the hard way in code, they/you will not believe how little needs to be done to save a business entity (like the customer's order) - check this out :-
All we need do is use the objects of the bound public properties to add a new order into the selected customer's order list - no need to worry about identities and how they are saved, we just need to deal with IDs that already exist.
Oh! we also need to see how simple it is to launch the ViewModel / View pair in the first place :-
Yes, we do need to have a bunch of public properties within our ViewModel for data binding, at is the secret to getting all this stuff to work so simply ;-0) Here are the private fields which match the PPs on a one to one basis :-
Once we click the green 'save' button the new order data is sent to the back-end data SQL server and persisted - then as if by magic the EF and WPF system show the newly allocated IDs for order and order lines - see below :-
Now we can use some of the other features to check-out what we have just done. The red button for Orders in the Entities group box shows this below :-
And the OrderLines can bee seen with the cyan button, a click to launch a RelayCommand :-
Finally we can look at the customer form and look into an appropriately nested combo box (drop list) - all this as we have to do little in code except get the Entity mapping correct in the first place - check below :-
Enough of this magic for now, in another post I may show how easy it was to save each new order line.
Hope this interests a few of you guys.
Best Regards,
Phil.
Wales, UK.
Well, around my time making picture frames (recently) I have managed to move-forward the demo app for Cologne, on LINQ and Entity Framework, with WPF/XAML and data binding. The results of the development are even amazing to me - he who designed it !
Entity Framework 6 takes so much of the mundane 'boring' bits out of database work that it almost makes me smile.
First of all lets see the finished input screen for a user to create and save a new Order for a selected customer :-
Note that all the screen data is 'data bound' as public properties in the ViewModel. The zero entries in the cells of the DataGrid show that the EF6 system has not yet saved the new order, as it will eventually allocate IDs when it does.
We have made the code as clean as it should be for an MVVM approach, and the code behind looks like this :-
For anyone who has had to use ADO.NET in the past years, and do all the database work the hard way in code, they/you will not believe how little needs to be done to save a business entity (like the customer's order) - check this out :-
All we need do is use the objects of the bound public properties to add a new order into the selected customer's order list - no need to worry about identities and how they are saved, we just need to deal with IDs that already exist.
Oh! we also need to see how simple it is to launch the ViewModel / View pair in the first place :-
Yes, we do need to have a bunch of public properties within our ViewModel for data binding, at is the secret to getting all this stuff to work so simply ;-0) Here are the private fields which match the PPs on a one to one basis :-
Once we click the green 'save' button the new order data is sent to the back-end data SQL server and persisted - then as if by magic the EF and WPF system show the newly allocated IDs for order and order lines - see below :-
Now we can use some of the other features to check-out what we have just done. The red button for Orders in the Entities group box shows this below :-
And the OrderLines can bee seen with the cyan button, a click to launch a RelayCommand :-
Finally we can look at the customer form and look into an appropriately nested combo box (drop list) - all this as we have to do little in code except get the Entity mapping correct in the first place - check below :-
Enough of this magic for now, in another post I may show how easy it was to save each new order line.
Hope this interests a few of you guys.
Best Regards,
Phil.
Wales, UK.