本文整理汇总了C#中Check.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Check.Create方法的具体用法?C# Check.Create怎么用?C# Check.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Check
的用法示例。
在下文中一共展示了Check.Create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStgPartitionCheck
public void CreateStgPartitionCheck()
{
// Now construct appropriate CHECK CONSTRAINT based on partition boundaries
// We need to distinguish between dates, unicode vs. nonunicode strings, and numeric
// values embedded in the partition boundarty collection. We do this by evaluating the
// data type of the partition column, and then construct the Check Constraint string
// appropriately quoted
Check partitionCheckConstraint = new Check(stgTable, "chk_" + stgTable.Name + "_partition_" + partitionNumber.ToString(System.Globalization.CultureInfo.InvariantCulture));
String leftBoundary = "";
String rightBoundary = "";
String partitionColumnName = partitionTable.PartitionSchemeParameters[0].Name;
String partitionColumnQuotedName = "[" + partitionColumnName + "]";
SqlDataType partitionColumnType = partitionTable.Columns[partitionColumnName].DataType.SqlDataType;
// Construct the minimum value predicate string in the check constraint definition
if (partitionNumber > 1)
{
leftBoundary = partitionColumnQuotedName + ((pf.RangeType == RangeType.Right) ? ">=" : ">") + localeIndependentText(partitionColumnType, pf.RangeValues[partitionNumber - 2]);
}
// Construct the maximum value predicate string in the check constraint definition
if (partitionNumber < pf.NumberOfPartitions)
{
rightBoundary = partitionColumnQuotedName + ((pf.RangeType == RangeType.Right) ? "<" : "<=") + localeIndependentText(partitionColumnType, pf.RangeValues[partitionNumber - 1]);
}
// Assemble the full Check Constraint string
// If the partitioning column is nullable
// If the partition is the leftmost, allow NULLs in the check constraint, otherwise add NOT NULL check constraint
String constraintText =
((partitionTable.Columns[partitionColumnName].Nullable) ? partitionColumnQuotedName +
((partitionNumber == 1) ? " IS NULL OR " : " IS NOT NULL AND ")
: ""
)
+ "(" + leftBoundary +
(((partitionNumber > 1) && (partitionNumber < pf.NumberOfPartitions)) ? " AND " : "") +
rightBoundary + ")";
partitionCheckConstraint.IsEnabled = true;
partitionCheckConstraint.Text = constraintText;
// Create the Check Constraint
scriptChunks.Add(partitionCheckConstraint.Script());
if (executeCommands) partitionCheckConstraint.Create();
}
示例2: CreateStgChecks
public void CreateStgChecks()
{
// Apply any Check constraints to the new table that are present on the Partition Table
foreach (Check chkConstr in partitionTable.Checks)
{
Check newCheck = new Check(stgTable, stgTable.Name + "_" + chkConstr.Name);
newCheck.IsChecked = chkConstr.IsChecked;
newCheck.IsEnabled = chkConstr.IsEnabled;
newCheck.Text = chkConstr.Text;
scriptChunks.Add(newCheck.Script());
if (executeCommands) newCheck.Create();
}
}