本文整理汇总了C#中Dialect.GetAddPrimaryKeyConstraintString方法的典型用法代码示例。如果您正苦于以下问题:C# Dialect.GetAddPrimaryKeyConstraintString方法的具体用法?C# Dialect.GetAddPrimaryKeyConstraintString怎么用?C# Dialect.GetAddPrimaryKeyConstraintString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dialect
的用法示例。
在下文中一共展示了Dialect.GetAddPrimaryKeyConstraintString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlConstraintString
/// <summary>
/// Generates the SQL string to create the named Primary Key Constraint in the database.
/// </summary>
/// <param name="d">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
/// <param name="constraintName">The name to use as the identifier of the constraint in the database.</param>
/// <param name="defaultCatalog"></param>
/// <param name="defaultSchema"></param>
/// <returns>
/// A string that contains the SQL to create the named Primary Key Constraint.
/// </returns>
public override string SqlConstraintString(Dialect.Dialect d, string constraintName, string defaultCatalog, string defaultSchema)
{
StringBuilder buf = new StringBuilder(
d.GetAddPrimaryKeyConstraintString(constraintName))
.Append('(');
int i = 0;
foreach (Column col in ColumnIterator)
{
buf.Append(col.GetQuotedName(d));
if (i < ColumnSpan - 1)
{
buf.Append(StringHelper.CommaSpace);
}
i++;
}
return buf.Append(StringHelper.ClosedParen).ToString();
}
示例2: SqlConstraintString
/// <summary>
/// Generates the SQL string to create the Unique Key Constraint in the database.
/// </summary>
/// <param name="d">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
/// <param name="constraintName"></param>
/// <param name="defaultSchema"></param>
/// <returns>
/// A string that contains the SQL to create the Unique Key Constraint.
/// </returns>
public override string SqlConstraintString(Dialect.Dialect d, string constraintName, string defaultSchema)
{
StringBuilder buf = new StringBuilder(
d.GetAddPrimaryKeyConstraintString(constraintName))
.Append('(');
bool commaNeeded = false;
foreach (Column col in ColumnCollection)
{
if (commaNeeded)
{
buf.Append(StringHelper.CommaSpace);
}
commaNeeded = true;
buf.Append(col.GetQuotedName(d));
}
return StringHelper.Replace(buf.Append(StringHelper.ClosedParen).ToString(), "primary key", "unique");
}
示例3: SqlConstraintString
/// <summary>
/// Generates the SQL string to create the Unique Key Constraint in the database.
/// </summary>
/// <param name="dialect">The <see cref="Dialect.Dialect"/> to use for SQL rules.</param>
/// <param name="constraintName"></param>
/// <param name="defaultCatalog"></param>
/// <param name="defaultSchema"></param>
/// <returns>
/// A string that contains the SQL to create the Unique Key Constraint.
/// </returns>
public override string SqlConstraintString(Dialect.Dialect dialect, string constraintName, string defaultCatalog, string defaultSchema)
{
StringBuilder buf = new StringBuilder(dialect.GetAddPrimaryKeyConstraintString(constraintName))
.Append(StringHelper.OpenParen);
bool commaNeeded = false;
bool nullable = false;
foreach (Column column in ColumnIterator)
{
if (!nullable && column.IsNullable)
nullable = true;
if (commaNeeded)
buf.Append(StringHelper.CommaSpace);
commaNeeded = true;
buf.Append(column.GetQuotedName(dialect));
}
return
!nullable || dialect.SupportsNotNullUnique
? StringHelper.Replace(buf.Append(StringHelper.ClosedParen).ToString(), "primary key", "unique")
: null;
}
示例4: DoToSqlConstraint
/// <summary>
/// Generates SQL for this constraint.
/// </summary>
/// <param name="dialect"></param>
/// <param name="constraintName">the name of this constraint</param>
/// <returns>an SQL string</returns>
protected override String DoToSqlConstraint(Dialect dialect, String constraintName)
{
StringBuilder sb = StringHelper.CreateBuilder()
.Append(dialect.GetAddPrimaryKeyConstraintString(constraintName))
.Append("(");
return AppendColumns(sb, dialect).Append(")").ToString();
}