fbpx
Welcome, Guest
Username: Password: Remember me
Share your code snippets, screen shots etc. here
  • Page:
  • 1

TOPIC: This Entity stuff just works ! Great with LINQ ...

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #1

  • Phil Hepburn
  • Phil Hepburn's Avatar Topic Author
  • Offline
  • Posts: 737
  • Karma: 7
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.

Please Log in or Create an account to join the conversation.

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #2

  • Phil Hepburn
  • Phil Hepburn's Avatar Topic Author
  • Offline
  • Posts: 737
  • Karma: 7
Hi guys,

I tried to attach a short video clip of me running the demo LINQ / Entity app - BUT - it can't be attached as it is an disallowed file format.

The video is here:

LINQ_Entit...ideo.mp4



Please can yo try to acquire this and then run it ? Let me know of either success or failure.

Good Luck and fingers crossed,
Phil.
Attachments:

    LINQ_Entit...ideo.mp4

Please Log in or Create an account to join the conversation.

Last edit: by robert.

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #3

Works - albeit i miss some sound ;)

Please Log in or Create an account to join the conversation.

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #4

  • Phil Hepburn
  • Phil Hepburn's Avatar Topic Author
  • Offline
  • Posts: 737
  • Karma: 7
Sorry Karl,

Office PC does not have a microphone, and I unfortunately don't speak German other than a few words and phrases ;-0)

Or is it the tip-tap and clitter-clatter of the keyboard that you miss ?

Regards, and thanks for testing,
Phil.

P.S. it surprised me how the link to the OneDrive file actually got the MP4 file to run as a video with just one click. Great this OneDrive technology.

Please Log in or Create an account to join the conversation.

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #5

dr philip h. hepburn wrote: ...Or is it the tip-tap and clitter-clatter of the keyboard that you miss ?

Nope - but, as my son would say, some "stylish" background music is a must ;->

Please Log in or Create an account to join the conversation.

Last edit: by FFF. Reason: typo

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #6

Phil,

dr philip h. hepburn wrote: Sorry Karl,

it surprised me how the link to the OneDrive file actually got the MP4 file to run as a video with just one click. Great this OneDrive technology.


No magic. I added the mp4 extension as an allowed extension, downloaded your MP4, acttached it to your message and inserted the document in the message.


Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

This Entity stuff just works ! Great with LINQ ... 2 years 2 months ago #7

  • Phil Hepburn
  • Phil Hepburn's Avatar Topic Author
  • Offline
  • Posts: 737
  • Karma: 7
Thanks Robert,

That is why (therefore) that is clicks and runs "like Magic! "

End result is great at this end.

Don't panic, I won't over-use it ;-0)

X# and VS 2017 working very well together here in Newport, UK.

Have a nice weekend, one and all.
Phil.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1