本文整理汇总了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);
}
}
示例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);
}
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}