Dblinq to MySQL

Source: Internet
Author: User

Since last year, I have been using LINQ. I don't want to change it because of convenience ..

Recently, the website needs to insert data into MySQL, but the built-in LINQ of vs2008 does not support MySQL.

After finding some information on the Internet, I finally found a MySQL-supported LINQ tool, which is dblinq. Post the method for later use.

 

I. tools:
Dblinq;
MySQL 5.0 or above, the programming host needs to be installed;
Vs2008

Ii. Generate the datacontext CS File
Dbmetal.exe-provider = mysql-Database: mydatebase-server: you host computer-user: MySQL user-Password: You PWD-namespace: mysqllinq-code: mysqllinq. CS-sprocs
// Note that the namespace is mysqllinq, and-sprocs must

3. Put the file datacontext cs into the project file
Note: Put the CS file in the first layer of the project, such as app_code, or in the internal library.

Using dblinq. LINQ;
Using dblinq. LINQ. Mapping;
(If it is not in app_code, add reference here)

4. Create a class project dalmysql in vs 2008 and add references

Dblinq. dll;
Dblinq. MySQL. dll;
MySQL. Data. dll;
// The above three can be found in DbLinq-0.18 \ build.
System. Data. LINQ. dll;
// In c: \ Program Files \ reference assemblies \ Microsoft \ framework \ v3.5 \ system. Data. LINQ. dll
// This is a reference !!!
5. Add a web_app project and reference dalmysql Project

6. Add a reference on the Aspx. CS page:

Using mysql. data;
Using mysql. Data. mysqlclient;
Using mysqllinq; // namespace of the datacontext CS File

// Omitted
String connstr = @ "Server = localhost; database = test; user = root; Pwd = ikmb; Port = 3306 ";

Mysqlconnection conn = new mysqlconnection (connstr );
Test T = new test (conn );
VaR DATA = from F in T. users select F;
Gridview1.datasource = data;
Gridview1.databind ();

 

Finally, download the package for dblinq.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.