當前位置: 首頁>>代碼示例>>C#>>正文


C# Int32.Name方法代碼示例

本文整理匯總了C#中System.Int32.Name方法的典型用法代碼示例。如果您正苦於以下問題:C# Int32.Name方法的具體用法?C# Int32.Name怎麽用?C# Int32.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Int32的用法示例。


在下文中一共展示了Int32.Name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddStoredProcedure

        /// <summary>
        /// Create and add a StoredProcedure instance to this Database.
        /// <para>The name parameter must be a valid one-part or two-part T-SQL identifier.  Square brackets around the name parts are optional.</para>
        /// <para>E.g. "my_stored_proc", "[my_stored_proc]", "my_schema.my_stored_proc", and "[my_schema].[my_stored_proc]" are all valid name identifiers.</para>
        /// <para>Names with more than two parts, or missing parts, are considered errors.</para>
        /// </summary>
        public StoredProcedure AddStoredProcedure(String name, Int32 versionNumber, params SqlParameter[] sqlParameters)
        {
            name.Name("name").NotNullEmptyOrOnlyWhitespace();
              versionNumber.Name("versionNumber").GreaterThan(0);

              name = IdentifierHelper.GetStrippedSqlIdentifier(name);
              var nameParts = name.Split(".".ToCharArray(), StringSplitOptions.None);

              /* It's an error if any of the name parts are empty,
             and this method only accepts one-part ([object name]) or
             two-part ([schema name].[object name]) T-SQL identifiers. */
              if (nameParts.Any(s => s.IsEmpty()) || (nameParts.Length > 2))
            throw new ArgumentExceptionFmt(Properties.Resources.InvalidStoredProcedureName, name);

              /* At this point, all of the name parts have been validated for correct form. */

              if (nameParts.Length == 1)
              {
            return this.Schemas.GetDefaultSchema().AddStoredProcedure(name, versionNumber, sqlParameters);
              }
              else
              {
            var schemaName = nameParts[0];
            var schema = this.Schemas.GetByName(schemaName);
            if (schema == null)
              throw new ExceptionFmt(Properties.Resources.SchemaNameNotFound, schemaName);

            var storedProcedureName = nameParts[1];

            return schema.AddStoredProcedure(storedProcedureName, versionNumber, sqlParameters);
              }
        }
開發者ID:ctimmons,項目名稱:cs_utilities,代碼行數:38,代碼來源:Database.cs

示例2: AddStoredProcedure

        public StoredProcedure AddStoredProcedure(String name, Int32 versionNumber, params SqlParameter[] sqlParameters)
        {
            name.Name("name").NotNullEmptyOrOnlyWhitespace();
              versionNumber.Name("versionNumber").GreaterThan(0);

              name = IdentifierHelper.GetBracketedSqlIdentifier(name);

              if (name.Contains("."))
            throw new ArgumentExceptionFmt(Properties.Resources.InvalidStoredProcedureNameForSchema, name);

              if (this.StoredProcedures.GetByName(name, versionNumber) == null)
              {
            var sp = new StoredProcedure(this, name, versionNumber, sqlParameters);
            this.StoredProcedures.Add(sp);
            return sp;
              }
              else
              {
            throw new ExceptionFmt(Properties.Resources.StoredProcedureAlreadyExists, name, versionNumber);
              }
        }
開發者ID:ctimmons,項目名稱:cs_utilities,代碼行數:21,代碼來源:Schema.cs


注:本文中的System.Int32.Name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。