LINQ-to-MySQL with DbLinq in C#
(Page 1 of 4 )
You are reading the sequel to the "LINQ to MySQL, Oracle and PostgreSQL Providers" article that was also published here on Dev Shed. In this part we are going to provide an example of implementing LINQ-to-MySQL using the DbLinq Provider. We are going to use the C# programming language in the Visual Studio 2008 IDE.
This article presumes a sound knowledge of LINQ and familiarity with RDBMS and C#. We are going to use the DbLinq Provider because it's free and open source. Even though right now it's heavily under development and doesn't match production quality, it is highly promising. MySQL is also a free open source RDBMS. And while LINQ was specifically designed for MS SQL Server and Access, providers are kind of struggling.
It is strongly advised that you reread the previous article of this series. On the third page of that article I summed up in a nutshell the basic guidelines for working with DbLinq, starting from how to configure through implementing it into your project. Eventually, we will still go through those actions in this article, too.
Before we begin I should clarify something. The application we are creating relies heavily on the database scheme. It also assumes that you are absolutely sure that MySQL server is up and running on your system. Likewise, it assumes that you know the details of the configuration of the server (like the IP address, or localhost if it runs on your system, root password, etc.).
As mentioned in our previous article, the example that will be presented here in this article is a minimalist hotel management application. There is a database called hotelsdb that contains numerous tables. Right now we are going to work only with the Hotels and Clients tables. These two tables have particular fields.
Hotels(IdHotel, Name, Rating, [...])
Clients(IdClient, Name, Address, ZIP, Phone)
The [...] part of the Hotels table stands for various foreign keys that maintain the relationships between other tables, such as the Location, Manager, Company, Facilities, and so forth. Obviously, you need to implement the application to your own database scheme. But this information was required so that you can imagine the scheme we are working with during this article. These are all of the details you need to know.
These being said, fire up your Visual Studio 2008 and let's begin.
Next: Preliminary Tasks >>
More C# Articles
More By Barzan "Tony" Antal