當前位置: 首頁>>代碼示例>>C#>>正文


C# OrmLiteConnectionFactory.OpenDbConnection方法代碼示例

本文整理匯總了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>();
     }
 }
開發者ID:hross,項目名稱:stock-info-downloader,代碼行數:7,代碼來源:Company.cs

示例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;
        }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:25,代碼來源:RegProListDB.cs

示例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;
            //    }

            //}
        }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:35,代碼來源:SiteProInfoDB.cs

示例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();
        }
開發者ID:josiahpeters,項目名稱:SimpleBudget,代碼行數:34,代碼來源:AutofacDataModule.cs

示例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();
        }
開發者ID:JonghoL,項目名稱:DasStaus,代碼行數:34,代碼來源:Utilities.cs

示例6: CreateDatabaseSession

        public IDbConnection CreateDatabaseSession()
        {
            var connectionFactory = new OrmLiteConnectionFactory(this.ConnectionString, false, SqlServerOrmLiteDialectProvider.Instance);

            IDbConnection connection = connectionFactory.OpenDbConnection();

            return connection;
        }
開發者ID:Hobbitron,項目名稱:WheelMUD,代碼行數:8,代碼來源:WheelMudSqlServerProvider.cs

示例7: Clear

 /// <summary>
 /// sqllit 刪除時候 文件大小不便 需要執行此方法來讓文件變小
 /// </summary>
 public void Clear()
 {
     _dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
        using (var db = _dbFactory.OpenDbConnection())
        {
        db.ExecuteNonQuery("VACUUM");
        }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:11,代碼來源:RegProListDB.cs

示例8: SiteProductsDb

 public SiteProductsDb()
 {
     _dbFactory = new OrmLiteConnectionFactory(ZnmDbConnectionString, SqlServerDialect.Provider);
     using (var db = _dbFactory.OpenDbConnection())
     {
         db.CreateTable<SiteProInfo>();
     }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:8,代碼來源:SiteProductsDb.cs

示例9: PromotionsDB

 public PromotionsDB()
 {
     _dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
     using (var db = _dbFactory.OpenDbConnection())
     {
         db.CreateTable<PromotionsInfo>();
     }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:8,代碼來源:PromotionsDB.cs

示例10: CommentDb

 public CommentDb()
 {
     _dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
     using (var db = _dbFactory.OpenDbConnection())
     {
         db.CreateTable<CommentInfo>();
     }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:8,代碼來源:CommentDB.cs

示例11: UserTransactionDb

 public UserTransactionDb()
 {
     _dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqliteDialect.Provider);
     using (var db = _dbFactory.OpenDbConnection())
     {
         db.CreateTable<UserTransaction>();
     }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:8,代碼來源:UserTransactionDB.cs

示例12: ApiRequstHistroyDB

 public ApiRequstHistroyDB()
 {
     _dbFactory = new OrmLiteConnectionFactory(ZnmDbConnectionString,SqlServerDialect.Provider);
     using (var db = _dbFactory.OpenDbConnection())
     {
         db.CreateTable<APIRequstHistroy>();
     }
 }
開發者ID:chennysnow,項目名稱:SimpleDemo,代碼行數:8,代碼來源:APIRequstHistroyDB.cs

示例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);
 }
開發者ID:eteeselink,項目名稱:sioux_tech_radar,代碼行數:9,代碼來源:SqLiteInMemoryFactory.cs

示例14: InsertData

        public void InsertData()
        {
            var dbFactory = new OrmLiteConnectionFactory(_connectionString, true, MySqlDialect.Provider);
            var db = dbFactory.OpenDbConnection();

            db.DropAndCreateTable<NflDotComGame>();
            db.InsertAll(_nflDotComGames);
        }
開發者ID:hecubu5,項目名稱:sportpicks,代碼行數:8,代碼來源:NflDotComGamesImporter.cs

示例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;
 }
開發者ID:kenvinnguyen,項目名稱:SES,代碼行數:8,代碼來源:OrmliteConnection.cs


注:本文中的ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。