本文整理汇总了C#中IDatabase.Create方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.Create方法的具体用法?C# IDatabase.Create怎么用?C# IDatabase.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.Create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetBlank
internal static void ResetBlank(IDatabase db)
{
/*
File.Copy(Path.Combine(TestHelpers.TestPaths.TestFolderPath, "src\\App.Config"),
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ica.aps.services.dll.config"), true);
*/
if (db.IsSqlServerCeProvider)
{
File.Copy(Path.Combine(TestHelpers.TestPaths.TestDataFolderPath, "aps_backup.sdf"),
Path.Combine(TestHelpers.TestPaths.TestDataFolderPath, "aps.sdf"), true);
}
else if (db.IsSqlServerProvider)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
conn.ChangeDatabase("master");
conn.Execute("DROP DATABASE aps");
conn.Execute("CREATE DATABASE aps");
/*
string sql = string.Format(@"RESTORE DATABASE {0} FROM DISK = '{1}' WITH REPLACE",
conn.Database,
Path.Combine(TestHelpers.TestPaths.TestDataFolderPath, "aps.bak"));
// change to master
conn.ChangeDatabase("master");
// perform restore
conn.Execute(sql);
*/
}
}
}
示例2: GetDailyGross
internal static DailyGross GetDailyGross(IDatabase db, Guid id)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
return conn.Query<DailyGross>("SELECT * FROM DailyGross WHERE DailyGrossID = @ID", new { ID = id }).FirstOrDefault();
}
}
示例3: GetDailyGrosses
internal static IEnumerable<DailyGross> GetDailyGrosses(IDatabase db, Employee emp)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
var rent = conn.Query<Rent>("SELECT * FROM Rent WHERE EmployeeID = @ID", new { ID = emp.EmployeeID }).First();
return conn.Query<DailyGross>("SELECT * FROM DailyGross WHERE RentID = @RentID", new { RentID = rent.RentID});
}
}
示例4: GetEmployee
internal static Employee GetEmployee(IDatabase db, string name)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
Employee employee = conn.Query<Employee>("SELECT * FROM Employee WHERE Name = '" + name + "'").First();
employee.Rents = conn.Query<Rent>("SELECT * FROM Rent WHERE EmployeeID = @ID", new { ID = employee.EmployeeID });
return employee;
}
}
示例5: TestSetup
public void TestSetup()
{
systemContext = new SystemContext();
var test = TestContext.CurrentContext.Test.Name;
if (test != "CreateNewContext") {
databaseContext = new DatabaseContext(systemContext, TestDbName);
}
if (test != "CreateNew" &&
test != "DatabaseNotExists" &&
test != "CreateNewContext") {
database = new Database(databaseContext);
database.Create(TestAdminUser, TestAdminPass);
database.Open();
}
}
示例6: ExecuteSQLScalar
internal static object ExecuteSQLScalar(IDatabase db, string sql)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
using (IDbCommand cmd = conn.CreateCommand())
{
//System.Diagnostics.Trace.Write(sql);
cmd.CommandText = sql;
return cmd.ExecuteScalar();
}
}
}
示例7: ExecuteSQL
internal static void ExecuteSQL(IDatabase db, string[] sqlcmds)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
IDbTransaction trans = conn.BeginTransaction();
foreach (string sql in sqlcmds)
{
conn.Execute(sql, null, trans);
}
trans.Commit();
}
}
示例8: ExecuteScript
internal static void ExecuteScript(IDatabase db, string scriptfile)
{
using (StreamReader reader = new StreamReader(scriptfile))
{
string sqlscript = reader.ReadToEnd();
string[] commands = sqlscript.Split(new string[] { "GO", "Go", "gO", "go"/*, ";" */}, StringSplitOptions.RemoveEmptyEntries);
if (commands != null && commands.Length > 0)
{
using (IDbConnection conn = db.Create())
{
conn.Open();
foreach (string command in commands)
{
if (!string.IsNullOrEmpty(command.Replace(System.Environment.NewLine, "")) &&
command != ";" &&
string.Compare(command, "go", true) != 0)
{
try
{
//System.Diagnostics.Trace.Write(command);
conn.Execute(command);
}
catch (Exception ex)
{
while (ex != null)
{
System.Diagnostics.Trace.Write(ex.Message);
ex = ex.InnerException;
}
}
}
}
}
}
}
}
示例9: CreateNew
public void CreateNew()
{
database = new Database(databaseContext);
Assert.DoesNotThrow(() => database.Create(TestAdminUser, TestAdminPass));
}