本文整理汇总了C#中ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.OpenDbConnection方法的具体用法?C# OrmLiteConnectionFactory.OpenDbConnection怎么用?C# OrmLiteConnectionFactory.OpenDbConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.OrmLite.OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.OpenDbConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCompanyTable
public static void CreateCompanyTable(OrmLiteConnectionFactory factory)
{
using (IDbConnection db = factory.OpenDbConnection())
{
db.CreateTableIfNotExists<Company>();
}
}
示例2: ReFreshProList
public void ReFreshProList()
{
List<RegProListInfo> lits;
_dbFactory = new OrmLiteConnectionFactory(MmbpriceDbConnectionString, SqlServerDialect.Provider);
try
{
using (var db = _dbFactory.OpenDbConnection())
{
lits =
db.SqlList<RegProListInfo>(
"select 0 as id,siteid,urladdress as ProListUrl,listsReg,singleReg,UrlReg,PriceReg,TitleReg,PicReg,isSellReg,CommentCountReg,commentUrlReg,idReg as SkuReg,shopIDReg,maxpageReg,pageStart,pageStep,'' as Remark,getdate() as UpdateTime from JD_Reg_SiteList where [type]=0");
}
_dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.CreateTable<RegProListInfo>(true);
}
AddRegProList(lits);
}
catch (Exception ex)
{
LogServer.WriteLog(ex, "DBError");
throw;
}
}
示例3: AddSiteProInfo
public void AddSiteProInfo(IEnumerable<SiteProInfo> siteList)
{
if (siteList == null) throw new ArgumentNullException("siteList");
_dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
try
{
db.InsertAll(siteList);
}
catch (Exception ex)
{
AddSitePro(siteList);
LogServer.WriteLog(ex, "DBError");
}
}
//var mmbdbFactory = new OrmLiteConnectionFactory(mmbpriceDBConnectionString, SqlServerDialect.Provider);
//using (var db = mmbdbFactory.OpenDbConnection())
//{
// try
// {
// db.CreateTable<SiteProInfo>();
// db.SaveAll(siteList);
// }
// catch (Exception ex)
// {
// LogServer.WriteLog(ex, "DBError");
// throw;
// }
//}
}
示例4: Load
protected override void Load(ContainerBuilder builder)
{
OrmLiteConfig.DialectProvider = PostgreSQLDialectProvider.Instance;
ServiceStack.OrmLite.OrmLiteConfig.DialectProvider.NamingStrategy = new LowercaseNamingStrategy();
var connectionFactory = new OrmLiteConnectionFactory("Server=127.0.0.1;Port=5432;Database=transactions;User Id=postgres;Password=canada;", false, PostgreSqlDialect.Provider);
using (var db = connectionFactory.OpenDbConnection())
{
DbSetup.Setup(db);
}
builder.Register(c => connectionFactory).As<IDbConnectionFactory>();
builder.Register(c => connectionFactory.Open()).As<IDbConnection>().InstancePerLifetimeScope();
builder.RegisterType<UserRepository>().As<IUserRepository>().As<IRepository<User>>().InstancePerLifetimeScope();
builder.RegisterType<BudgetRepository>().As<IBudgetRepository>().As<IRepository<Budget>>().InstancePerLifetimeScope();
builder.RegisterType<CategoryRepository>().As<ICategoryRepository>().As<IRepository<Category>>().InstancePerLifetimeScope();
builder.RegisterType<TransactionRepository>().As<ITransactionRepository>().As<IRepository<Transaction>>().InstancePerLifetimeScope();
//builder.RegisterType<UserRepository>().As<IRepository<User>>().InstancePerLifetimeScope();
//builder.RegisterType<BudgetRepository>().As<IRepository<Budget>>().InstancePerLifetimeScope();
//builder.RegisterType<CategoryRepository>().As<IRepository<Category>>().InstancePerLifetimeScope();
//builder.RegisterType<TransactionRepository>().As<IRepository<Transaction>>().InstancePerLifetimeScope();
builder.RegisterType<BillRepository>().As<IBillRepository>().As<IRepository<Bill>>().InstancePerLifetimeScope();
builder.RegisterType<RepositoryUnitOfWork>().As<IRepositoryUnitOfWork>().InstancePerLifetimeScope();
builder.RegisterType<SimpleBudgetService>().As<ISimpleBudgetService>().InstancePerLifetimeScope();
// make sure our mock provider is accessible through IVoiceProvider and MockProvider for when we need to fake validation for things.
//builder.RegisterType<MockProvider>().As<IVoiceProvider>().As<MockProvider>().InstancePerLifetimeScope();
//builder.RegisterType<VoiceCore>().As<IVoiceCore>().As<VoiceCore>().InstancePerLifetimeScope();
}
示例5: GetOpenConnection
public static IDbConnection GetOpenConnection()
{
string connString = string.Empty;
IOrmLiteDialectProvider provider = null;
if (ConnectionString.StartsWith("postgres://"))
{
connString = GenerateConnectionStringForPostgreSQL(ConnectionString);
provider = PostgreSqlDialect.Provider;
}
else if (ConnectionString.StartsWith("sqlserver://"))
{
connString = GenerationConnectionStringForSqlServer(ConnectionString);
provider = SqlServerDialect.Provider;
}
else
{
connString = ConnectionString;
var providerString = config.Get("provider");
switch (providerString)
{
case "postgres":
provider = PostgreSqlDialect.Provider;
break;
case "sqlserver":
provider = SqlServerDialect.Provider;
break;
default:
break;
}
}
var dbFactory = new OrmLiteConnectionFactory(connString, provider);
return dbFactory.OpenDbConnection();
}
示例6: CreateDatabaseSession
public IDbConnection CreateDatabaseSession()
{
var connectionFactory = new OrmLiteConnectionFactory(this.ConnectionString, false, SqlServerOrmLiteDialectProvider.Instance);
IDbConnection connection = connectionFactory.OpenDbConnection();
return connection;
}
示例7: Clear
/// <summary>
/// sqllit 删除时候 文件大小不便 需要执行此方法来让文件变小
/// </summary>
public void Clear()
{
_dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.ExecuteNonQuery("VACUUM");
}
}
示例8: SiteProductsDb
public SiteProductsDb()
{
_dbFactory = new OrmLiteConnectionFactory(ZnmDbConnectionString, SqlServerDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.CreateTable<SiteProInfo>();
}
}
示例9: PromotionsDB
public PromotionsDB()
{
_dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.CreateTable<PromotionsInfo>();
}
}
示例10: CommentDb
public CommentDb()
{
_dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.CreateTable<CommentInfo>();
}
}
示例11: UserTransactionDb
public UserTransactionDb()
{
_dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.CreateTable<UserTransaction>();
}
}
示例12: ApiRequstHistroyDB
public ApiRequstHistroyDB()
{
_dbFactory = new OrmLiteConnectionFactory(ZnmDbConnectionString,SqlServerDialect.Provider);
using (var db = _dbFactory.OpenDbConnection())
{
db.CreateTable<APIRequstHistroy>();
}
}
示例13: SqLiteInMemoryFactory
//private static IDbConnection TheOneConnection;
public SqLiteInMemoryFactory()
{
ConnectionString = MemoryConnectionString;
OrmLiteConnectionFactory = new OrmLiteConnectionFactory (MemoryConnectionString, false, SqliteDialect.Provider);
var db= OrmLiteConnectionFactory.OpenDbConnection ();
db.CreateTableIfNotExists<Thing> ();
db.TableExists ("Thing").ShouldBe(true);
}
示例14: InsertData
public void InsertData()
{
var dbFactory = new OrmLiteConnectionFactory(_connectionString, true, MySqlDialect.Provider);
var db = dbFactory.OpenDbConnection();
db.DropAndCreateTable<NflDotComGame>();
db.InsertAll(_nflDotComGames);
}
示例15: openConn
public IDbConnection openConn()
{
string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
var dbFactory = new OrmLiteConnectionFactory(connectionString,SqlServerOrmLiteDialectProvider.Instance);
IDbConnection dbConn = dbFactory.OpenDbConnection();
OrmLiteConfig.DialectProvider.UseUnicode = true;
return dbConn;
}