LINQ to MySQL, Oracle and PostgreSQL Providers - More About DbLinq
(Page 3 of 4 )
Now that we have presented a few solutions on the previous page, you can decide which route to follow. On this page we will focus only on DbLinq and explain the basic guidelines for how to work with it. Keep in mind that we will keep it simple, since the sequel to this article will entirely focus on showing a real-world applicable LINQ-to-MySQL implementation (application) based on DbLinq in VC# 3.5.
First and foremost, there are the following requirements for DbLinq. You need to have .NET Framework 3.5 installed. But this is self-explanatory since it comes with Visual Studio 2008. You are going to need this IDE to develop C# or VB applications using the DbLinq provider. However, .NET Framework 3.5 is required on execution of the compiled code as well. So the executable cannot be run without the framework.
Furthermore, you need to download the latest available release of DbLinq. The project is called dblinq2007 and it’s featured on Google Code. You can download the archived (.zip extension) version of each release. The source codes are available via the svn page (Subversion). Let’s assume you don’t want to mess with the source code right now, so you download one of the archived releases. Extract everything.
You will notice that there are numerous folders. Under the srcDbMetal folder you are going to find various similar batch files, such as run_myMetal.bat, run_oraMetal.bat, run_sqliteMetal.bat, run_ingMetal.bat, and so forth. These are the batch files, which are needed to be executed to create the appropriate C# files representing your database. This step is necessary and should be executed after the batch files are edited.
With MySQL, you can see that the run_myMetal.bat contains the following:
binDbMetal.exe -provider=MySql -database:your_db -server:your_server -user:root -password:your_pass -namespace:namespace -code:filename.cs -sprocs
You either copy the batch file where DbMetal.exe is located (in the bin) folder and edit the script accordingly or execute the script from the main root folder of DbLinq. As soon as the script finishes, the C# file as requested will be generated. Now there’s one final step: copying the necessary files into your project. In the case of MySQL, these are the following:
That is all for now. On the next page you’ll read more about LINQ documentation.
Next: Closing Thoughts >>
More MS SQL Server Articles
More By Barzan "Tony" Antal