本文整理汇总了C#中IDbProvider类的典型用法代码示例。如果您正苦于以下问题:C# IDbProvider类的具体用法?C# IDbProvider怎么用?C# IDbProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDbProvider类属于命名空间,在下文中一共展示了IDbProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TwitterModule
public TwitterModule(IDbProvider dbProvider)
{
Get["/{slug}"] = p =>
{
var mvp = dbProvider.GetDb()
.mvps.FindAllBySlug(p["slug"])
.WithLinks()
.FirstOrDefault()
;
if (mvp == null)
{
return HttpStatusCode.NotFound;
}
TwitterJson model = TwitterJson.ParseSingle(mvp);
return Response.AsJson(model);
};
Get["/"] = _ =>
{
var mvps = dbProvider.GetDb().mvps.WithLinks();
TwitterJson model = TwitterJson.ParseList(mvps);
return Response.AsJson(model);
};
}
示例2: PagedQueryBuilder
public PagedQueryBuilder(TableInfo info,IDbProvider provider)
{
_info = info;
_provider = provider;
}
示例3: ConnectionString
public IDbContext ConnectionString(string connectionString, IDbProvider fluentDataProvider, string providerName = null)
{
if(string.IsNullOrEmpty(providerName))
providerName = fluentDataProvider.ProviderName;
var adoNetProvider = System.Data.Common.DbProviderFactories.GetFactory(providerName);
return ConnectionString(connectionString, fluentDataProvider, adoNetProvider);
}
示例4: DatabaseSchema
/// <summary>
/// Initializes a new instance of a DatabaseSchema.
/// </summary>
/// <param name="dbprovider"></param>
public DatabaseSchema(IDbProvider dbprovider)
{
if (dbprovider == null)
throw new ArgumentNullException("dbprovider");
_dbprovider = dbprovider;
}
示例5: SetUpMocks
public void SetUpMocks()
{
provider = MockRepository.GenerateMock<IDbProvider>();
IDbConnection connection = MockRepository.GenerateMock<IDbConnection>();
provider.Stub(x => x.CreateConnection()).Return(connection).Repeat.Once();
// Creating a query (setting DbProvider property)
// will call new DbParameters(IDbProvider), which is a real pain to mock.
// to store the declared parameters.
command = MockRepository.GenerateMock<IDbCommand>();
//This IDbCommand is used as a container for the underlying parameter collection.
provider.Stub(x => x.CreateCommand()).Return(command).Repeat.Once();
//Create a real instance of IDbParameters to stored the declared parameters
IDbProvider realDbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient");
IDbParameters dbParameters = new DbParameters(realDbProvider);
//Pass real instance into mock instance.
command.Stub(x => x.Parameters).Return(dbParameters.DataParameterCollection).Repeat.Once();
provider.Stub(x => x.CreateCommand()).Return(command).Repeat.Once();
// done with init of DbParameters mock/stubbing
}
示例6: GenerateSql
public string GenerateSql(IDbProvider provider, string parameterPrefix, BuilderData data)
{
var setSql = "";
foreach (var column in data.Columns)
{
if (setSql.Length > 0)
setSql += ", ";
setSql += string.Format("{0} = {1}{2}",
provider.EscapeColumnName(column.ColumnName),
parameterPrefix,
column.ParameterName);
}
var whereSql = "";
foreach (var column in data.Where)
{
if (whereSql.Length > 0)
whereSql += " and ";
whereSql += string.Format("{0} = {1}{2}",
provider.EscapeColumnName(column.ColumnName),
parameterPrefix,
column.ParameterName);
}
var sql = string.Format("update {0} set {1} where {2}",
data.ObjectName,
setSql,
whereSql);
return sql;
}
示例7: Serialize
/// <summary>
/// Serializes the specified <see cref="IDbProvider"/> into an <see cred="IConfiguration" /> node.
/// </summary>
public static IConfiguration Serialize(IDbProvider dbProvider)
{
IConfiguration providerConfig = new MutableConfiguration("provider", dbProvider.Id, dbProvider.Id);
providerConfig.Attributes[DataConstants.ATTRIBUTE_NAME] = dbProvider.Id;
providerConfig.Attributes[DataConstants.ATTRIBUTE_ASSEMBLYNAME] = dbProvider.AssemblyName;
providerConfig.Attributes[DataConstants.ATTRIBUTE_COMMANDBUILDERCLASS] = dbProvider.CommandBuilderClass;
providerConfig.Attributes[DataConstants.ATTRIBUTE_COMMANDCLASS] = dbProvider.DbCommandClass;
providerConfig.Attributes[DataConstants.ATTRIBUTE_CONNECTIONCLASS] = dbProvider.DbConnectionClass;
providerConfig.Attributes[DataConstants.ATTRIBUTE_DESCRIPTION] = dbProvider.Description;
providerConfig.Attributes[DataConstants.ATTRIBUTE_DEFAULT] = dbProvider.IsDefault.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_ENABLED] = dbProvider.IsEnabled.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_PARAMETERDBTYPECLASS] = dbProvider.ParameterDbTypeClass;
providerConfig.Attributes[DataConstants.ATTRIBUTE_PARAMETERDBTYPEPROPERTY] = dbProvider.ParameterDbTypeProperty;
providerConfig.Attributes[DataConstants.ATTRIBUTE_PARAMETERPREFIX] = dbProvider.ParameterPrefix;
providerConfig.Attributes[DataConstants.ATTRIBUTE_PARAMETERPREFIX] = dbProvider.ParameterPrefix;
providerConfig.Attributes[DataConstants.ATTRIBUTE_SETDBPARAMETERPRECISION] = dbProvider.SetDbParameterPrecision.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_SETDBPARAMETERSCALE] = dbProvider.SetDbParameterScale.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_SETDBPARAMETERSIZE] = dbProvider.SetDbParameterSize.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_USEDERIVEPARAMETERS] = dbProvider.UseDeriveParameters.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_USEPARAMETERPREFIXINPARAMETER] = dbProvider.UseParameterPrefixInParameter.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_USEPARAMETERPREFIXINSQL] = dbProvider.UseParameterPrefixInSql.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_USEPOSITIONALPARAMETERS] = dbProvider.UsePositionalParameters.ToString().ToLower();
providerConfig.Attributes[DataConstants.ATTRIBUTE_ALLOWMARS] = dbProvider.AllowMARS.ToString().ToLower();
return providerConfig;
}
示例8: DBSemaphore
/// <summary>
/// Initializes a new instance of the <see cref="DBSemaphore"/> class.
/// </summary>
/// <param name="tablePrefix">The table prefix.</param>
/// <param name="sql">The SQL.</param>
/// <param name="defaultSQL">The default SQL.</param>
/// <param name="dbProvider">The db provider.</param>
public DBSemaphore(string tablePrefix, string sql, string defaultSQL, IDbProvider dbProvider) {
log = LogManager.GetLogger(GetType());
this.sql = defaultSQL;
this.tablePrefix = tablePrefix;
SQL = sql;
adoUtil = new AdoUtil(dbProvider);
}
示例9: IDbCommandCreatorFactory
/// <summary>
/// Initializes a new instance of the <see cref="IDbCommandCreatorFactory"/> class.
/// </summary>
public IDbCommandCreatorFactory(IDbProvider dbProvider, CommandType commandType, string sql, IDbParameters declaredParameters)
{
this.dbProvider = dbProvider;
this.sql = sql;
this.commandType = commandType;
this.declaredParameters = declaredParameters;
}
示例10: AddParam
public static DbParameter AddParam(this DbCommand cmd, IDbProvider provider, string name, object value)
{
var p = cmd.CreateParameter();
provider.SetupParameter(p,name,value);
cmd.Parameters.Add(p);
return p;
}
示例11: SqlFuConnection
public SqlFuConnection(DbConnection cnx,IDbProvider provider)
{
cnx.MustNotBeNull();
provider.MustNotBeNull();
_conex = cnx;
_provider = provider;
}
示例12: Inject
public void Inject(IDbProvider dbProvider, IReadWriteLockManager lockManager)
{
Debug.Assert(dbProvider != null && lockManager != null);
if (this.dbProvider != null || this.lockManager != null)
throw new InvalidOperationException();
this.dbProvider = dbProvider;
this.lockManager = lockManager;
}
示例13: SetUp
public void SetUp()
{
ctx =
new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/autoDeclarativeServices.xml");
dbProvider = ctx["DbProvider"] as IDbProvider;
transactionManager = ctx["adoTransactionManager"] as IPlatformTransactionManager;
}
示例14: CreateDbProvider
public void CreateDbProvider()
{
IApplicationContext ctx =
new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/adoTemplateTests.xml");
Assert.IsNotNull(ctx);
dbProvider = ctx["DbProvider"] as IDbProvider;
Assert.IsNotNull(dbProvider);
}
示例15: InsertSqlBuilder
public InsertSqlBuilder(TableInfo info,object data,IDbProvider provider,InsertSqlOptions options)
{
_info = info;
_data = data;
_provider = provider;
_options = options;
options.EnsureTableName(info);
}