本文整理汇总了C#中IPropertyInstance.Length方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyInstance.Length方法的具体用法?C# IPropertyInstance.Length怎么用?C# IPropertyInstance.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyInstance
的用法示例。
在下文中一共展示了IPropertyInstance.Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
/// <summary>
/// Applies length based on byte[].
/// </summary>
/// <param name="instance">The instance.</param>
public void Apply( IPropertyInstance instance )
{
var lengthAttributes = instance.Property.MemberInfo.GetCustomAttributes (
typeof( ColumnLengthAttribute ), false );
if ( lengthAttributes.Length > 0 )
{
var columnLength = ( ColumnLengthAttribute )lengthAttributes[0];
instance.Length ( columnLength.Length );
}
else
{
instance.Length ( ByteArrayDefaultLength );
}
}
示例2: ApplyStringLength
private static void ApplyStringLength(int stringLength, IPropertyInstance target)
{
if (stringLength > 0)
{
target.Length(stringLength);
}
}
示例3: Apply
public void Apply(IPropertyInstance instance)
{
if (instance.Name=="Name")
{
instance.Length(100);
instance.Not.Nullable();
}
}
示例4: Apply
public void Apply(IPropertyInstance instance)
{
if (instance.Property.PropertyType != typeof(string))
return;
var memberInfo = instance.Property.MemberInfo;
var stringLengthAttribute = memberInfo.GetCustomAttribute<StringLengthAttribute>();
var isDbLengthAttribute = memberInfo.GetCustomAttribute<IsDBLengthAttribute>();
if (stringLengthAttribute != null && isDbLengthAttribute != null)
{
instance.Length(stringLengthAttribute.MaximumLength);
}
else
{
instance.CustomType<VarcharMax>();
instance.Length(4001);
}
}
示例5: Apply
public void Apply(IPropertyInstance target)
{
var attribute =
Attribute.GetCustomAttribute(target.Property.MemberInfo, typeof(StringLengthAttribute)) as
StringLengthAttribute;
if (attribute != null)
{
target.Length(attribute.MaximumLength);
}
}
示例6: StringConvention
private static void StringConvention(IPropertyInstance instance)
{
if (instance.Type == typeof (String))
{
object[] attributes = instance.EntityType.GetProperty(instance.Name)
.GetCustomAttributes(typeof (LengthAttribute), false);
if (attributes.Length > 0)
{
LengthAttribute length = attributes[0] as LengthAttribute;
if (length != null) instance.Length(length.Length);
}
}
}
示例7: Apply
/// <summary>
/// Sets the length of the property based on the Name.
/// </summary>
/// <param name="propertyInstance">The property instance.</param>
/// <param name="columnName">Name of the column.</param>
public static void Apply( IPropertyInstance propertyInstance, string columnName )
{
var lengthAttributes = propertyInstance.Property.MemberInfo.GetCustomAttributes (
typeof( ColumnLengthAttribute ), false );
if ( lengthAttributes.Length > 0 )
{
var columnLength = ( ColumnLengthAttribute )lengthAttributes[0];
propertyInstance.Length ( columnLength.Length );
}
else if ( columnName.EndsWith ( "Code" ) )
{
propertyInstance.Length ( CodeLength );
}
else if ( columnName.EndsWith ( "Number" ) )
{
propertyInstance.Length ( NumberLength );
}
else if ( columnName.EndsWith ( "Name" ) )
{
propertyInstance.Length ( NameLength );
}
else if ( columnName.EndsWith ( "Note" ) )
{
propertyInstance.Length ( NoteLength );
}
else if ( columnName.EndsWith ( "Description" ) )
{
propertyInstance.Length ( DescriptionLength );
}
else if ( columnName.EndsWith ( "Identifier" ) )
{
propertyInstance.Length ( IdentifierLength );
}
else if ( columnName.EndsWith ( "Value" ) )
{
propertyInstance.Length ( ValueLength );
}
}
示例8: Apply
public void Apply(IPropertyInstance propertyMapping)
{
try
{
if (propertyMapping.Type == typeof(byte[]))
{
propertyMapping.Length(int.MaxValue);
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
示例9: Apply
public void Apply(IPropertyInstance instance)
{
var meta = QueryFluentMetadata.FindMetadataFor(instance.EntityType, instance.Property.Name);
if (meta != null)
{
if (meta.Required.HasValue && meta.Required.Value)
{
instance.Not.Nullable();
}
var maxLength = meta.GetMaximumLength();
if (maxLength.HasValue && maxLength.Value > 0)
{
instance.Length(maxLength.Value);
}
}
}
示例10: Apply
public void Apply(IPropertyInstance instance)
{
if (instance.EntityType.Name == "AuditLog")
instance.Length(10000);
//if (instance.Name == "OriginalValue")
//{
// instance.Length(10000);
//}
//if (instance.Name == "NewValue")
//{
// instance.Length(10000);
//}
}
示例11: Apply
public void Apply(IPropertyInstance target)
{
target.Length(20);
}
示例12: Apply
public void Apply(IPropertyInstance propertyMapping)
{
propertyMapping.Length(4000);
}
示例13: Apply
public void Apply(IPropertyInstance instance)
{
instance.Length(short.MaxValue);
}
示例14: Apply
public void Apply(IPropertyInstance instance)
{
instance.Length(Enum.GetNames(instance.Property.PropertyType).Max(name => name.Length));
instance.CustomType(typeof(string));
}
示例15: Apply
public void Apply(IPropertyInstance instance)
{
instance.Length(int.MaxValue);
//instance.CustomSqlType("varbinary(MAX)");
}