本文整理汇总了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());
}
示例2: PetaPocoTests
public PetaPocoTests()
{
_db = new Database(Config.Connex, Config.SqlServerProviderName);
_db.EnableAutoSelect = false;
_db.EnableNamedParams = false;
_db.OpenSharedConnection();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}