当前位置: 首页>>代码示例>>C#>>正文


C# Database.OpenSharedConnection方法代码示例

本文整理汇总了C#中Database.OpenSharedConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Database.OpenSharedConnection方法的具体用法?C# Database.OpenSharedConnection怎么用?C# Database.OpenSharedConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database.OpenSharedConnection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var systemDatabase = new Database("ImportAccounts");
            systemDatabase.OpenSharedConnection();

            var file = "Goelearning_Transactions-AllAccounts-FY2015.csv";
            var loadedFile = FileLoadHelper.LoadFile(file);
            var transactions = FileLoadHelper.GetTransactions(loadedFile);

            TransactionPersister.SaveTransactions(systemDatabase, transactions);

            //TransactionPersister.CreateBankAccountsWithZeroBalanceIfNotExist(systemDatabase, transactions);

            TransactionPersister.BuildReconciles(systemDatabase);

            TransactionPersister.UpdateRunningBalances(systemDatabase);

            foreach (var x in transactions)
            {
                Console.WriteLine(x.ToJsonString() + Environment.NewLine);
            }
            var reporter = new TransactionReporter();

            var goelearningCompanyid = 1;
            var report = reporter.GetTransactionReport(systemDatabase, goelearningCompanyid, new DateTime(2014, 7, 1), new DateTime(2015, 6, 30));

            Console.WriteLine(report.ToJsonString());
        }
开发者ID:throbbo,项目名称:ImportAccounts,代码行数:28,代码来源:Program.cs

示例2: PetaPocoTests

 public PetaPocoTests()
 {
     _db = new Database(Config.Connex, Config.SqlServerProviderName);
     _db.EnableAutoSelect = false;
     _db.EnableNamedParams = false;
     _db.OpenSharedConnection();
 }
开发者ID:eugman,项目名称:SqlFu,代码行数:7,代码来源:PetaPocoTests.cs

示例3: TransactionsAll

        public ActionResult TransactionsAll(GetTransactionQueryModel query)
        {
            var systemDatabase = new Database("ImportAccounts");
            systemDatabase.OpenSharedConnection();

            var handler = new GetTransactionsAllReportHandler();
            var result = handler.Handle(query);

            return View(result);
        }
开发者ID:throbbo,项目名称:ImportAccounts,代码行数:10,代码来源:ReportController.cs

示例4: ConstructorWithConnectionDBTypeIsolationTypeAndSettings

        public void ConstructorWithConnectionDBTypeIsolationTypeAndSettings()
        {
            var db = new Database(TestDatabase.Connection, new SqlServer2012DatabaseType(), IsolationLevel.ReadUncommitted, false);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof(SqlServer2012DatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNotNull(db.Connection);

            db.Dispose();
            Assert.IsNotNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:15,代码来源:ConstructorTests.cs

示例5: ConstructorWithConnectionAndDBType

        public void ConstructorWithConnectionAndDBType()
        {
            var db = new Database(TestDatabase.Connection, new SqlServer2012DatabaseType());
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof(SqlServer2012DatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNotNull(db.Connection);

            db.Dispose();
            Assert.IsNotNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:15,代码来源:ConstructorTests.cs

示例6: ConstructorWithConnectionDBTypeAndIsolationLevel

        public void ConstructorWithConnectionDBTypeAndIsolationLevel()
        {
            var dbType = GetConfiguredDatabaseType();
            var db = new Database(TestDatabase.Connection, dbType, IsolationLevel.ReadUncommitted);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(dbType.GetType(), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNotNull(db.Connection);

            db.Dispose();
            Assert.IsNotNull(db.Connection);
        }
开发者ID:schotime,项目名称:NPoco,代码行数:16,代码来源:ConstructorTests.cs

示例7: ConstructorWithConnectionStringAndDBProvider

        public void ConstructorWithConnectionStringAndDBProvider()
        {
            var dbType = new SqlServer2012DatabaseType();
            var provider = DbProviderFactories.GetFactory(dbType.GetProviderName());
            var db = new Database(TestDatabase.ConnectionString, provider);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof(SqlServerDatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:17,代码来源:ConstructorTests.cs

示例8: ConstructorWithConnectionStringProviderNameAndSettings

        public void ConstructorWithConnectionStringProviderNameAndSettings()
        {
            var db = new Database(TestDatabase.ConnectionString, TestDatabase.ProviderName, false);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof(SqlServerDatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:15,代码来源:ConstructorTests.cs

示例9: ConstructorWithConnectionStringDBProviderAndSettings

        public void ConstructorWithConnectionStringDBProviderAndSettings()
        {
            var dbType = GetConfiguredDatabaseType();
            var provider = DbProviderFactories.GetFactory(dbType.GetProviderName());
            var db = new Database(TestDatabase.ConnectionString, provider, false);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(dbType.GetType(), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:aalex675,项目名称:NPoco,代码行数:17,代码来源:ConstructorTests.cs

示例10: OpenConnection

        public void OpenConnection(Database database)
        {
            DataProvider = ProviderFactory.GetProvider(Configuration.GetConnectionString(), Configuration.ProviderName);
            Database = database;

            Database.OpenSharedConnection();

            foreach (var map in m_mapping)
            {
                if (map.Table != null)
                    continue;

                ITable table;
                if (map.Type.GetInterface(typeof(IManualGeneratedRecord).FullName) != null)
                {
                    var instance = Activator.CreateInstance(map.Type, true);
                    table = ( (IManualGeneratedRecord)instance ).GetTableInformation(DataProvider);
                }
                else
                {
                    table = map.Type.ToSchemaTable(DataProvider);
                }

                map.Table = table;

                var query = map.Table.CreateSql;

                Database.Execute(query);
            }
        }
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:30,代码来源:DatabaseAccessor.cs

示例11: ConstructorWithConnectionStringAndProviderName

        public void ConstructorWithConnectionStringAndProviderName()
        {
            var dbType = GetConfiguredDatabaseType();
            var db = new Database(TestDatabase.ConnectionString, dbType, SqlClientFactory.Instance);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(dbType.GetType(), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:schotime,项目名称:NPoco,代码行数:16,代码来源:ConstructorTests.cs


注:本文中的Database.OpenSharedConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。