本文整理汇总了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);
}
}
示例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);
}
}