本文整理汇总了C#中IConnectionProvider类的典型用法代码示例。如果您正苦于以下问题:C# IConnectionProvider类的具体用法?C# IConnectionProvider怎么用?C# IConnectionProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnectionProvider类属于命名空间,在下文中一共展示了IConnectionProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccessSchemaProvider
public AccessSchemaProvider(IConnectionProvider connectionProvider)
{
if (connectionProvider == null)
throw new ArgumentNullException("connectionProvider");
_connectionProvider = connectionProvider;
}
示例2: GetCitiesNames
public GetCitiesNames(
IConnectionProvider connectionProvider,
IEventAggregator eventAggregator)
{
_connectionProvider = connectionProvider;
_eventAggregator = eventAggregator;
}
示例3: Execute
protected virtual string Execute(IQuery query,
IDictionary<string, string> parameters, IConnectionProvider provider) {
using (IDbConnection connection = provider.CreateConnection())
using (var builder = new CommandBuilder(connection)) {
builder
.SetText(query.QueryText)
.SetType(GetCommandType(query.Options))
.SetTimeout(query.Options
.GetInteger(Strings.kCommandTimeoutOption, 30));
BindParameters(builder, query.Parameters, parameters);
string preferred_json_collection = query.Options
.GetString(Strings.kJsonCollectionOption,
Strings.kDefaultJsonCollection);
IDbCommand cmd = builder.Build();
connection.Open();
string response =
(query.QueryMethod == QueryMethod.Get)
? ExecuteReader(cmd, query, preferred_json_collection)
: ExecuteNonQuery(cmd, query, preferred_json_collection);
connection.Close();
return response;
}
}
示例4: ClusterHeartBeat
public ClusterHeartBeat(Cluster cluster, IConnectionProvider provider, TimeSpan pollingInterval)
{
Cluster = cluster;
NodeChecks = new Dictionary<INode, IFixedSizeStack<ConnectivityCheck>>();
ConnectionProvider = provider;
PollingInterval = pollingInterval;
}
示例5: Execute
/// <summary>Executes <see cref="UpdateStatement"/>. Bulk updates are executed in multiple round trips - one update at a time.</summary>
public int Execute(UpdateStatement update, DbmsType dbms, IConnectionProvider conn, out CommandExecutionStatistics lastExecutedCommandInfo, int cmdTimeout = 30)
{
if (IsBulkUpdate(update))
return ExecuteBulkUpdate(update, dbms, conn, out lastExecutedCommandInfo, cmdTimeout);
else
return ExecuteSingleTableUpdate(update, dbms, conn, out lastExecutedCommandInfo, cmdTimeout);
}
示例6: GetReservationsForUser
public GetReservationsForUser(
IConnectionProvider connectionProvider,
IEventAggregator eventAggregator)
{
_connectionProvider = connectionProvider;
_eventAggregator = eventAggregator;
}
示例7: GetExpectedSchemaProvider
private ISchemaProvider GetExpectedSchemaProvider(IConnectionProvider connectionProvider)
{
var serverVersion = GetServerVersion(connectionProvider);
if (!string.IsNullOrEmpty(serverVersion) && serverVersion.StartsWith("5"))
return new MysqlSchemaProvider(connectionProvider, new MysqlSchemaDataProvider50(connectionProvider));
return new MysqlSchemaProvider(connectionProvider, new MysqlSchemaDataProvider40(connectionProvider));
}
示例8: TryGetProvider
public override bool TryGetProvider(string connectionString, out IConnectionProvider provider, out Exception exception)
{
try
{
var _ = new SqlConnectionStringBuilder(connectionString);
}
catch (KeyNotFoundException ex)
{
exception = ex;
provider = null;
return false;
}
catch (FormatException ex)
{
exception = ex;
provider = null;
return false;
}
catch (ArgumentException ex)
{
exception = ex;
provider = null;
return false;
}
provider = new SqlConnectionProvider(connectionString);
exception = null;
return true;
}
示例9: GetDao
private static IEntityDAO GetDao(IConnectionProvider conn, IEntity entity, IEntityDaoFactory daoFactory)
{
if (daoFactory != null)
return daoFactory.GetEntityDAO(entity, conn);
else
return DefaultDaoFactory.GetEntityDAO(entity, conn);
}
示例10: SetUp
public void SetUp()
{
provider = MockRepository.GenerateMock<IConnectionProvider>();
connection = MockRepository.GenerateMock<IDbConnection>();
command = MockRepository.GenerateMock<IDbCommand>();
reader = MockRepository.GenerateMock<IDataReader>();
}
示例11: ESSession
public ESSession(IConnectionProvider connectionProvider)
{
if (Current != null)
throw new ElasticSearchException("Cannot create a new session while there is one already active.");
ConnectionProvider = connectionProvider;
Current = this;
}
示例12: EnsureOpenConnection
private static bool EnsureOpenConnection(IConnectionProvider conn)
{
bool connIsOpennedLocally = !conn.IsOpen;
if (connIsOpennedLocally)
conn.OpenConnection();
return connIsOpennedLocally;
}
示例13: ExecuteQuery
/// <summary>
/// Creates and executes query using the given ConnectionProvider.
/// </summary>
/// <param name="conn">Connection provider.</param>
/// <param name="cmdText">Command text.</param>
/// <param name="parameters">Command parameters.</param>
/// <param name="cmdType">Command type (stored procedure or text).</param>
/// <param name="cmdTimeout">Set timeout for specified command.</param>
/// <param name="dataTableName">Name of the datatable that will be returned. May be null.</param>
/// <returns>DataTable containing retrieved data.</returns>
public static DataTable ExecuteQuery(IConnectionProvider conn, string cmdText, DbParameterCollection parameters, CommandType cmdType, string dataTableName, int cmdTimeout)
{
IDbCommand cmd = CreateCommand(conn.DBMS, cmdText, parameters, cmdType, cmdTimeout);
cmd.Connection = conn.Connection;
IDataAdapterBuilder builder = DbmsComponentFactory.GetComponent<IDataAdapterBuilder>(conn.DBMS);
IDataAdapter adapter = builder.BuildAdapter(cmd);
bool connIsOpennedLocally = EnsureOpenConnection(conn);
try
{
AssignExistingPendingTransactionToCommand(conn, cmd);
// Execute query.
DataSet data = new DataSet();
data.Locale = CultureInfo.InvariantCulture;
adapter.Fill(data);
PopulateOutputParameterValues(parameters, cmd);
DataTable table = (data.Tables.Count > 0)
? data.Tables[0]
: new DataTable() { Locale = CultureInfo.InvariantCulture };
if (!string.IsNullOrEmpty(dataTableName))
table.TableName = dataTableName;
return table;
}
finally
{
CloseConnectionIfLocal(conn, connIsOpennedLocally);
cmd.Dispose();
IDisposable disposableAdapter = adapter as IDisposable;
if (disposableAdapter != null)
disposableAdapter.Dispose();
}
}
示例14: FlumeSession
public FlumeSession(IConnectionProvider connectionProvider)
{
if (Current != null)
throw new BrokenCollectorException("Cannot create a new session while there is one already active.");
ConnectionProvider = connectionProvider;
Current = this;
}
示例15: AttributeTypeRepository
public AttributeTypeRepository(IConnectionProvider connectionProvider, IDataTypeConverter dataTypeConverter,
IEntityAttributeTypeRepository entityAttributeTypeRepository)
{
_connectionProvider = connectionProvider;
_dataTypeConverter = dataTypeConverter;
_entityAttributeTypeRepository = entityAttributeTypeRepository;
}