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


C# IDatabase.Create方法代码示例

本文整理汇总了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);
                    */
                }
            }
        }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:33,代码来源:Data.cs

示例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();
     }
 }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:8,代码来源:Data.cs

示例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});                
     }
 }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:9,代码来源:Data.cs

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

        }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:11,代码来源:Data.cs

示例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();
            }
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:17,代码来源:DatabaseTests.cs

示例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();                    
                }
            }
        }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:14,代码来源:Data.cs

示例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();
     }
 }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:13,代码来源:Data.cs

示例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;
                             }
                         }
                     }
                 }
             }
         }
     }            
 }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:36,代码来源:Data.cs

示例9: CreateNew

 public void CreateNew()
 {
     database = new Database(databaseContext);
     Assert.DoesNotThrow(() => database.Create(TestAdminUser, TestAdminPass));
 }
开发者ID:furesoft,项目名称:deveeldb,代码行数:5,代码来源:DatabaseTests.cs


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