SqlServerDataContextOptions<TAdoDbContext>.SqlServerDataContextOptions(string connectionString) Constructor
.NET Standard 2.x
Initializes a new instance of the SqlServerDataContextOptions<TAdoDbContext> class by passing the connection string as a parameter.
Namespace: SnapObjects.Data.SqlServer
Assembly: SnapObjects.Data.SqlServer.dll
Syntax
public SqlServerDataContextOptions(string connectionString) : base(connectionString)
Parameters
connectionString
System.String
A string containing connection information about how to connect to the data source.
Examples
The following code example uses a connection string to initialize an instance of the SqlServerDataContextOptions<SqlServerContext>
class.
using Appeon.ApiDoc.Models;
using SnapObjects.Data;
using SnapObjects.Data.SqlServer;
using System;
namespace Appeon.ApiDoc.SqlServerDataContextOptions_GenericExamples
{
public class SqlServerDataContextOptions_GenericExample
{
public void Example()
{
var options = new SqlServerDataContextOptions<SqlServerContext>(CONNECTION_STRING);
var dataContext = new SqlServerDataContext(options);
Console.WriteLine(dataContext.ContextOptions.DatabaseType);
/*This code produces the following output:
SqlServer
*/
}
}
}
Applies to
.NET Standard
2.x