本文整理汇总了C#中Generator.GeneratePrimaryKeys方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.GeneratePrimaryKeys方法的具体用法?C# Generator.GeneratePrimaryKeys怎么用?C# Generator.GeneratePrimaryKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator.GeneratePrimaryKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static int Main(string[] args)
{
if (args.Length < 2 || args.Length > 6)
{
PrintUsageGuide();
return 2;
}
else
{
try
{
string connectionString = args[0];
string outputFileLocation = args[1];
bool includeData = true;
bool includeSchema = true;
bool saveImageFiles = false;
bool keepSchemaName = false;
bool preserveDateAndDateTime2 = false;
bool sqlite = false;
System.Collections.Generic.List<string> exclusions = new System.Collections.Generic.List<string>();
for (int i = 2; i < args.Length; i++)
{
if (args[i].StartsWith("dataonly"))
{
includeData = true;
includeSchema = false;
}
if (args[i].StartsWith("schemaonly"))
{
includeData = false;
includeSchema = true;
}
if (args[i].StartsWith("saveimages"))
saveImageFiles = true;
if (args[i].StartsWith("keepschema"))
keepSchemaName = true;
if (args[i].StartsWith("preservedateanddatetime2"))
preserveDateAndDateTime2 = true;
if (args[i].StartsWith("exclude:"))
ParseExclusions(exclusions, args[i]);
if (args[i].StartsWith("sqlite"))
{
sqlite = true;
includeSchema = true;
}
}
using (IRepository repository = new ServerDBRepository(connectionString, keepSchemaName))
{
Helper.FinalFiles = outputFileLocation;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
var generator = new Generator(repository, outputFileLocation, false, preserveDateAndDateTime2, sqlite, keepSchemaName);
generator.ExcludeTables(exclusions);
if (sqlite)
{
generator.GenerateSqlitePrefix();
if (includeSchema)
{
Console.WriteLine("Generating the tables....");
generator.GenerateTable(false);
}
Console.WriteLine("Generating the data....");
generator.GenerateTableContent(false);
Console.WriteLine("Generating the indexes....");
generator.GenerateIndex();
generator.GenerateSqliteSuffix();
}
else
{
// The execution below has to be in this sequence
if (includeSchema)
{
Console.WriteLine("Generating the tables....");
generator.GenerateTable(includeData);
}
if (includeData)
{
Console.WriteLine("Generating the data....");
generator.GenerateTableContent(saveImageFiles);
}
if (includeSchema)
{
Console.WriteLine("Generating the primary keys....");
generator.GeneratePrimaryKeys();
Console.WriteLine("Generating the indexes....");
generator.GenerateIndex();
Console.WriteLine("Generating the foreign keys....");
generator.GenerateForeignKeys();
}
}
Helper.WriteIntoFile(generator.GeneratedScript, outputFileLocation, generator.FileCounter, sqlite);
Console.WriteLine("Sent script to output file(s) : {0} in {1} ms", Helper.FinalFiles, (sw.ElapsedMilliseconds).ToString());
return 0;
}
}
//.........这里部分代码省略.........
示例2: Main
//.........这里部分代码省略.........
{
using (var repo = Helper.CreateRepository(args[1]))
{
var dch = new DataContextHelper();
dch.GenerateWPDataContext(repo, args[1], args[2]);
}
return 0;
}
else
{
PrintUsageGuide();
return 2;
}
#endif
}
else
{
for (int i = 2; i < args.Length; i++)
{
if (args[i].Contains("dataonly"))
{
includeData = true;
includeSchema = false;
}
if (args[i].Contains("schemaonly"))
{
includeData = false;
includeSchema = true;
}
if (args[i].Contains("saveimages"))
saveImageFiles = true;
if (args[i].Contains("sqlazure"))
sqlAzure = true;
if (args[i].StartsWith("exclude:"))
ParseExclusions(exclusions, args[i]);
}
using (IRepository repository = Helper.CreateRepository(connectionString))
{
Helper.FinalFiles = outputFileLocation;
#if V40
var generator = new Generator4(repository, outputFileLocation, sqlAzure);
#else
var generator = new Generator(repository, outputFileLocation, sqlAzure);
#endif
generator.ExcludeTables(exclusions);
Console.WriteLine("Generating the tables....");
#if V31
generator.GenerateTable(false);
#else
generator.GenerateTable(includeData);
#endif
if (sqlAzure && includeSchema)
{
Console.WriteLine("Generating the primary keys (SQL Azure)....");
generator.GeneratePrimaryKeys();
}
if (includeData)
{
Console.WriteLine("Generating the data....");
generator.GenerateTableContent(saveImageFiles);
}
if (!sqlAzure && includeSchema)
{
Console.WriteLine("Generating the primary keys....");
generator.GeneratePrimaryKeys();
}
if (includeSchema)
{
Console.WriteLine("Generating the indexes....");
generator.GenerateIndex();
Console.WriteLine("Generating the foreign keys....");
generator.GenerateForeignKeys();
}
Helper.WriteIntoFile(generator.GeneratedScript, outputFileLocation, generator.FileCounter);
}
Console.WriteLine("Sent script to output file(s) : {0} in {1} ms", Helper.FinalFiles, (sw.ElapsedMilliseconds).ToString());
return 0;
}
}
catch (System.Data.SqlServerCe.SqlCeException e)
{
Console.WriteLine(Helper.ShowErrors(e));
return 1;
}
catch (System.Data.SqlClient.SqlException es)
{
Console.WriteLine(Helper.ShowErrors(es));
return 1;
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex);
return 1;
}
}
}