本文整理汇总了C#中SQLHelper.Batch方法的典型用法代码示例。如果您正苦于以下问题:C# SQLHelper.Batch方法的具体用法?C# SQLHelper.Batch怎么用?C# SQLHelper.Batch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLHelper
的用法示例。
在下文中一共展示了SQLHelper.Batch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDatabase
/// <summary>
/// Creates a database out of the structure it is given
/// </summary>
/// <param name="Database">Database structure</param>
/// <param name="ConnectionString">The connection string to the database's location</param>
public static void CreateDatabase(Database Database, string ConnectionString)
{
string Command = BuildCommands(Database);
string[] Splitter = { "\n" };
string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
ConnectionString = Regex.Replace(ConnectionString, "Pooling=(.*?;)", "", RegexOptions.IgnoreCase) + ";Pooling=false;";
string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "", RegexOptions.IgnoreCase);
using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
{
Helper.ExecuteNonQuery();
}
using (SQLHelper Helper = new SQLHelper("", ConnectionString, CommandType.Text))
{
IBatchCommand Batcher = Helper.Batch();
for (int x = 1; x < Commands.Length; ++x)
{
if (Commands[x].Contains("CREATE TRIGGER") || Commands[x].Contains("CREATE FUNCTION"))
{
if (Batcher.CommandCount > 0)
{
Helper.ExecuteNonQuery();
Batcher = Helper.Batch();
}
Batcher.AddCommand(Commands[x], CommandType.Text);
if (x < Commands.Length - 1)
{
Helper.ExecuteNonQuery();
Batcher = Helper.Batch();
}
}
else
{
Batcher.AddCommand(Commands[x], CommandType.Text);
}
}
Helper.ExecuteNonQuery();
}
}