MySqlDataContext.MySqlDataContext(MySqlConnection dbConnection) Constructor
.NET Standard 2.x
Initializes a new instance of the MySqlDataContext class by passing the MySqlConnection
type object as a parameter.
Namespace: SnapObjects.Data.MySql
Assembly: SnapObjects.Data.MySql.dll
Syntax
public MySqlDataContext(MySqlConnection dbConnection) : base(dbConnection, new MySqlDataContextOptions(System.String.Empty))
Parameters
dbConnection
MySqlConnection
The connection object which is a MySqlConnection
instance.
Examples
The following code example uses a MySqlConnection
object to initialize an instance of the MySqlDataContext
class.
using Appeon.ApiDoc.Models;
using MySql.ManagedDataAccess.Client;
using SnapObjects.Data;
using SnapObjects.Data.MySql;
using System;
namespace Appeon.ApiDoc.MySqlDataContextExamples
{
public class MySqlDataContextExample
{
public void Example2()
{
DataContext dataContext = new MySqlDataContext(new MySqlConnection(CONNECTION_STRING));
Console.WriteLine(dataContext.ContextOptions.DatabaseType);
/*This code produces the following output:
MySql
*/
}
}
}
Applies to
.NET Standard
2.x