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


C# Database.ExecuteSqlCommand方法代码示例

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


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

示例1: InitializeDatabase

 public void InitializeDatabase(Database db)
 {
     foreach (string command in _initializeCommands)
     {
         db.ExecuteSqlCommand(command);
     }
 }
开发者ID:rhwy,项目名称:EFMap,代码行数:7,代码来源:DbInitializer.cs

示例2: ExecuteCommand

 private static void ExecuteCommand(Database database, string command)
 {
     if (!string.IsNullOrWhiteSpace(command))
     {
         Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0} - Executing command:\r\n{1}", DateTime.Now, command), "Information");
         database.ExecuteSqlCommand(command);
     }
 }
开发者ID:modulexcite,项目名称:StudentSuccessDashboard,代码行数:8,代码来源:ScriptResourceExecutor.cs

示例3: With_valid_arguments_doesnt_throw

            public void With_valid_arguments_doesnt_throw()
            {
                var internalContextMock = new Mock<InternalContextForMock>();
                internalContextMock.Setup(m => m.EnsureTransactionsForFunctionsAndCommands).Returns(true);
                var database = new Database(internalContextMock.Object);
                var parameters = new object[1];

                Assert.NotNull(database.ExecuteSqlCommand("query", parameters));
                internalContextMock.Verify(m => m.ExecuteSqlCommand(TransactionalBehavior.EnsureTransaction, "query", parameters), Times.Once());

                Assert.NotNull(database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "query", parameters));
                internalContextMock.Verify(
                    m => m.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "query", parameters), Times.Once());
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:DatabaseTests.cs

示例4: With_null_parameters_throws

            public void With_null_parameters_throws()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                Assert.Equal("parameters", Assert.Throws<ArgumentNullException>(() => database.ExecuteSqlCommand("query", null)).ParamName);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:6,代码来源:DatabaseTests.cs

示例5: With_whitespace_SQL_throws

            public void With_whitespace_SQL_throws()
            {
                var database = new Database(new Mock<InternalContextForMock>().Object);

                Assert.Equal(
                    Strings.ArgumentIsNullOrWhitespace("sql"),
                    Assert.Throws<ArgumentException>(() => database.ExecuteSqlCommand(" ")).Message);
            }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:8,代码来源:DatabaseTests.cs

示例6: With_valid_arguments_doesnt_throw

            public void With_valid_arguments_doesnt_throw()
            {
                var internalContextMock = new Mock<InternalContextForMock>();
                var database = new Database(internalContextMock.Object);

                Assert.NotNull(database.ExecuteSqlCommand("query"));
                internalContextMock.Verify(m => m.ExecuteSqlCommand("query", new object[0]), Times.Once());
            }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:8,代码来源:DatabaseTests.cs

示例7: Create

 /// <summary>
 /// Creates the SQLite-Database.
 /// </summary>
 public void Create(Database db, DbModel model)
 {
     var sqliteSqlGenerator = new SqliteSqlGenerator();
     string sql = sqliteSqlGenerator.Generate(model.StoreModel);
     db.ExecuteSqlCommand(TransactionalBehavior.EnsureTransaction, sql);
 }
开发者ID:exp10der,项目名称:SQLiteCodeFirst,代码行数:9,代码来源:SqliteDatabaseCreator.cs


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