本文整理汇总了C#中SqlGenerator类的典型用法代码示例。如果您正苦于以下问题:C# SqlGenerator类的具体用法?C# SqlGenerator怎么用?C# SqlGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlGenerator类属于命名空间,在下文中一共展示了SqlGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateSql
/// <summary> Generates the Sql </summary>
/// <param name="name"> The name. </param>
/// <param name="primaryKeys"> The item. </param>
/// <param name="properties"> The properties. </param>
/// <returns> The sql. </returns>
public string GenerateSql(string name, IList<Property> primaryKeys, IList<Property> properties)
{
SqlGenerator generator = new SqlGenerator();
string sql = generator.Insert(name, properties);
return sql;
}
示例2: WriteSql
/// <summary>
/// We delegate the writing of the fragment to the appropriate type.
/// </summary>
/// <param name="writer"> </param>
/// <param name="sqlGenerator"> </param>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
if (null != _sqlFragments)
{
foreach (var o in _sqlFragments)
{
var str = (o as String);
if (null != str)
{
writer.Write(str);
}
else
{
var sqlFragment = (o as ISqlFragment);
if (null != sqlFragment)
{
sqlFragment.WriteSql(writer, sqlGenerator);
}
else
{
throw new InvalidOperationException();
}
}
}
}
}
示例3: WriteSql
/// <summary>
/// Write this symbol out as a string for sql. This is just
/// the new name of the symbol (which could be the same as the old name).
/// We rename columns here if necessary.
/// </summary>
/// <param name="writer"> </param>
/// <param name="sqlGenerator"> </param>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
if (NeedsRenaming)
{
int i;
if (sqlGenerator.AllColumnNames.TryGetValue(NewName, out i))
{
string newNameCandidate;
do
{
++i;
newNameCandidate = NewName + i.ToString(CultureInfo.InvariantCulture);
}
while (sqlGenerator.AllColumnNames.ContainsKey(newNameCandidate));
sqlGenerator.AllColumnNames[NewName] = i;
NewName = newNameCandidate;
}
// Add this column name to list of known names so that there are no subsequent
// collisions
sqlGenerator.AllColumnNames[NewName] = 0;
// Prevent it from being renamed repeatedly.
NeedsRenaming = false;
}
writer.Write(SqlGenerator.QuoteIdentifier(NewName));
}
示例4: WriteSql
/// <summary>
/// Write out the TOP part of sql select statement
/// It basically writes TOP (X) [WITH TIES].
/// The brackets around X are ommited for Sql8.
/// </summary>
/// <param name="writer"> </param>
/// <param name="sqlGenerator"> </param>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
writer.Write("TOP ");
if (sqlGenerator.SqlVersion
!= SqlVersion.Sql8)
{
writer.Write("(");
}
TopCount.WriteSql(writer, sqlGenerator);
if (sqlGenerator.SqlVersion
!= SqlVersion.Sql8)
{
writer.Write(")");
}
writer.Write(" ");
if (WithTies)
{
writer.Write("WITH TIES ");
}
}
示例5: ExtractColumn
public ExtractColumn(IDatabaseAdapter src, IDatabaseAdapter dest, ITableConversionRules rules)
{
_src = src;
_dest = dest;
_rules = rules;
_destGenerator = new SqlGenerator(_dest);
_extractedColumns = new List<ExtractedColumn>();
}
示例6: WriteSql
/// <summary>
/// Write out the SKIP part of sql select statement
/// It basically writes SKIP (X).
/// </summary>
/// <param name="writer"></param>
/// <param name="sqlGenerator"></param>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
writer.Write("SKIP (");
this.SkipCount.WriteSql(writer, sqlGenerator);
writer.Write(")");
writer.Write(" ");
}
示例7: WriteSql
// <summary>
// Write out the OFFSET part of sql select statement
// It basically writes OFFSET X ROWS.
// </summary>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
writer.Write("OFFSET ");
SkipCount.WriteSql(writer, sqlGenerator);
writer.Write(" ROWS ");
}
示例8: WriteSql
/// <summary>
/// Write out the FIRST part of sql select statement
/// It basically writes FIRST (X).
/// </summary>
/// <param name="writer"></param>
/// <param name="sqlGenerator"></param>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
writer.Write("FIRST (");
this.FirstCount.WriteSql(writer, sqlGenerator);
writer.Write(")");
writer.Write(" ");
}
示例9: About
public ActionResult About()
{
var filter = new SqlGenerator(SqlGenerator.SqlTypes.Select, "Transact");
filter.SelectStatementLimit = 1000;
var baseModel = ModelBase.LoadModel<TransactModel>(filter);
return View(baseModel.ToList());
// return View();
}
示例10: ModificationCommandBatchFactory
public ModificationCommandBatchFactory(
[NotNull] SqlGenerator sqlGenerator,
[NotNull] DbContextConfiguration contextConfiguration)
{
Check.NotNull(sqlGenerator, "sqlGenerator");
Check.NotNull(contextConfiguration, "contextConfiguration");
_sqlGenerator = sqlGenerator;
_contextConfiguration = contextConfiguration;
}
示例11: WriteSqlIfUsed
/// <summary>
/// Writes that fragment that represents the optional column
/// if the usage manager says it is used.
/// </summary>
/// <param name="writer"> </param>
/// <param name="sqlGenerator"> </param>
public bool WriteSqlIfUsed(SqlWriter writer, SqlGenerator sqlGenerator, string separator)
{
if (m_usageManager.IsUsed(m_symbol))
{
writer.Write(separator);
m_builder.WriteSql(writer, sqlGenerator);
return true;
}
return false;
}
示例12: CreateTableIfNotExists
public static void CreateTableIfNotExists(this IDao dao, string tableName, Type entityType, params string[] pks)
{
//如果表已经存在则跳过
bool existTable = ExistsTable(dao, tableName);
if (existTable) {
return;
}
var sqlGen = new SqlGenerator();
var sql = sqlGen.CreateSqlScript(tableName, entityType, pks);
dao.Execute(sql);
}
示例13: FromTargetConfigs
private IEnumerable<GeneratorResult> FromTargetConfigs(SqlTargetConfig sqlConfig)
{
var args = new GeneratorArguments<SqlTargetConfig>(sqlConfig, AtomsFolder, AtomCreator.LoadDefaults(AtomsFolder));
var sqlResult = new SqlGenerator().Generate(args);
sqlResult.OutputPath = sqlConfig.OutputPath;
if (Directory.Exists(sqlResult.OutputPath))
{
foreach (var file in Directory.EnumerateFiles(sqlResult.OutputPath, "*.generated.sql", SearchOption.AllDirectories))
{
sqlResult.Deletions.Add(file);
}
}
string redGateFile = Path.Combine(sqlConfig.OutputPath, "RedGateDatabaseInfo.xml");
Log.Information("Looking for redgate database info xml at {RedGateDatabaseInfoXml}", redGateFile);
if (sqlResult.DataFiles.Any() &&
File.Exists(redGateFile))
{
Log.Information("Found redgate file, updating...");
var regate = XDocument.Load(uri: redGateFile);
var dataFiles = regate.Root.Elements("DataFileSet").First();
var allDataFiles = dataFiles.Elements("DataFile")
.Select(n => n.Value).Union(sqlResult.DataFiles, StringComparer.OrdinalIgnoreCase).ToList();
dataFiles.Elements("Count")
.First()
.Value = allDataFiles.Count().ToString();
Log.Information("DataFiles Count: {DataFileCount}", allDataFiles.Count());
dataFiles.Elements("DataFile").Remove();
dataFiles.Add(allDataFiles.Select(s => new XElement("DataFile", s)));
var genResult = new GeneratorResult()
{
OutputPath = _config.OutputPath
};
genResult.AddOutput("RedGateDatabaseInfo.xml", regate.ToString());
yield return genResult;
}
yield return sqlResult;
}
示例14: WriteSql
/// <summary>
/// Write out the TOP part of sql select statement
/// It basically writes TOP (X) [WITH TIES].
/// </summary>
/// <param name="writer"></param>
/// <param name="sqlGenerator"></param>
public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
{
writer.Write("TOP (");
this.TopCount.WriteSql(writer, sqlGenerator);
writer.Write(")");
writer.Write(" ");
if (this.WithTies)
{
writer.Write("WITH TIES ");
}
}
示例15: DmlFunctionSqlGenerator
public DmlFunctionSqlGenerator(DbProviderManifest providerManifest)
{
DebugCheck.NotNull(providerManifest);
var sqlManifest = providerManifest as SqlProviderManifest;
if (sqlManifest == null)
{
throw new ArgumentException(Strings.Mapping_Provider_WrongManifestType(typeof(SqlProviderManifest)));
}
_sqlGenerator = new SqlGenerator(sqlManifest.SqlVersion);
}