当前位置: 首页>>代码示例>>C#>>正文


C# Check.Script方法代码示例

本文整理汇总了C#中Check.Script方法的典型用法代码示例。如果您正苦于以下问题:C# Check.Script方法的具体用法?C# Check.Script怎么用?C# Check.Script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Check的用法示例。


在下文中一共展示了Check.Script方法的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();
        }
开发者ID:lucazav,项目名称:SqlServerPartitionManagementUtility,代码行数:41,代码来源:PartitionManagement.cs

示例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();
       }
 }
开发者ID:lucazav,项目名称:SqlServerPartitionManagementUtility,代码行数:13,代码来源:PartitionManagement.cs


注:本文中的Check.Script方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。