I did it!! Entity Framework 6 with X#...
Posted: Tue Mar 12, 2019 3:19 am
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).
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.
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).
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.