forked from jonwagner/Insight.Database
-
Notifications
You must be signed in to change notification settings - Fork 0
MySql Provider
jbright edited this page Nov 24, 2014
·
4 revisions
The MySql Provider allows Insight.Database to work with your MySql database.
Before you can use Insight.Database with MySql, you must first install and register the provider in your application. The provider allows Insight to handle some of the connection-specific database issues.
- Install the Insight.Database.Providers.MySql package from NuGet.
- Bulk Copy is not supported.
- Table Valued Parameters are not supported.
- XML columns are not supported.
You'll most likely need to add the MySql.Data nuget package to your project as well.
Install-Package MySql.Data
If you're using a web application, you'll probably want to add the RegisterProvider in the Application_Start of your Global.asa.cs file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Insight.Database.Providers.MySql;
namespace MyWebProject
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// Insight Database changes.
MySqlInsightDbProvider.RegisterProvider();
}
}
}
Then, instead of the SQL connection string builder, you can use this:
var db = new MySqlConnectionStringBuilder("... your connection string ...");
And that will allow you to get your mySql beers:
var beers = db
.Connection()
.As<IBarTender>()
.GetMeBeer(2)
.ToList();
- Home
- About
- Getting Started
- Connections
- Execute
- Getting Results
- Advanced Results & Mapping
- Insert/Update Considerations
- Data Types
- Write Even Less Code
- Performance & Speed
- Other Topics
- Supported Databases
- Working with the Code