I did it!! Entity Framework 6 with X#...

This forum is meant for examples of X# code.

Post Reply
Anonymous

I did it!! Entity Framework 6 with X#...

Post by Anonymous »

In a previous thread I said that I already had a working Entity Framework 6 data access project in C# that I had written a year or more ago as I was studying Entity Framework against Sql Server to access data that is presently used by my Visual FoxPro application.

So tonight I sat down and created a new X# Winforms application in Visual Studio 2017, and was determined I would see if I could get X# to use the DLL from my existing C#/EF Data project, and if I could write some little bit of X# Core code to use the existing classes in that project to get data from my Sql Server and show it on a form. I have only learned a little about this platform so far (remember I am a VFP guy and C#), but it's not all that different, right? And, Johan has been enlightening me a little, and I have spent about 2-3 hours so far reviewing code samples and forums posts.

It only took about 30 minutes to get the darn thing working. As a C#/.Net/Visual Studio experienced user, it was pretty easy. Had to add some DLL references and/or Nuget packages, but that was to be expected (I mean, this is .Net after all).

In code, I created a Business Object instanced from one of my data access object class, then I call a method on that BO which returns an IEnumable list of Customers, then I iterate over that with X# Foreach, and I wrote some text to a form control from the records in the data set. You can see the result and my code in the attached image. (Remember I am an X# newby, so if my code is poor, please let me know).
2019-03-11_22-15-09.png
2019-03-11_22-15-09.png (208.36 KiB) Viewed 341 times
It's basically the same exact thing I have done in C# before. I mean, it's almost *exactly* the same exact code, except for using := and the way you declare your strongly typed variables.
Attachments
Code.jpg
Code.jpg (79.12 KiB) Viewed 341 times
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

I did it!! Entity Framework 6 with X#...

Post by wriedmann »

Hi Matt,
congratulations!
The great thing about X# is that you can combine new tecnology like the Entity Framework with your VFP code and syntax.
I have a bit of experience with X# Core, but when it comes to development speed, I'm much faster when I can use Xbase features like arrays and codeblocks together with all the functions from the runtime.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

I did it!! Entity Framework 6 with X#...

Post by lumberjack »

Matt,

Well done Sir! You amaze me more and more. We need more of your type on the X# team/community/family. We will conquer the XBase world.

Thanks also for the WhatsApp calls (hands free if somebody is worried) while you drive to work, it starts to feel as if we knowing each other already for years... Well, we both speak the XBase lingo, so what is there more to expect?

This is a great example. Maybe you need to, as you mentioned send us a link or two of what you have on YouTube based on your VFP work. The new Channel X# is going to happen: Ladies and gentlemen you tuned in to Channel X#, today we will be talking about, well you guess Xbase and .NET... :P
______________________
Johan Nel
Boshof, South Africa
Post Reply