本文整理汇总了C#中IProperty.GetMaxLength方法的典型用法代码示例。如果您正苦于以下问题:C# IProperty.GetMaxLength方法的具体用法?C# IProperty.GetMaxLength怎么用?C# IProperty.GetMaxLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProperty
的用法示例。
在下文中一共展示了IProperty.GetMaxLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPrimitiveTypeReference
private static IEdmPrimitiveTypeReference GetPrimitiveTypeReference(
IProperty efProperty)
{
var kind = EdmPrimitiveTypeKind.None;
var propertyType = efProperty.ClrType;
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(System.Nullable<>))
{
propertyType = propertyType.GetGenericArguments()[0];
}
if (!s_primitiveTypeKindMap.TryGetValue(propertyType, out kind))
{
return null;
}
switch (kind)
{
default:
return EdmCoreModel.Instance.GetPrimitive(
kind, efProperty.IsNullable);
case EdmPrimitiveTypeKind.Binary:
return EdmCoreModel.Instance.GetBinary(
efProperty.GetMaxLength() < 0, efProperty.GetMaxLength(),
efProperty.IsNullable);
case EdmPrimitiveTypeKind.Decimal:
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
//return EdmCoreModel.Instance.GetDecimal(
// efProperty.Precision, efProperty.Scale,
// efProperty.Nullable);
return EdmCoreModel.Instance.GetDecimal(efProperty.IsNullable);
case EdmPrimitiveTypeKind.String:
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
return EdmCoreModel.Instance.GetString(
efProperty.GetMaxLength() < 0, efProperty.GetMaxLength(),
null, efProperty.IsNullable);
case EdmPrimitiveTypeKind.DateTimeOffset:
case EdmPrimitiveTypeKind.Duration:
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
//return EdmCoreModel.Instance.GetTemporal(
// kind, efProperty.Precision, efProperty.Nullable);
return EdmCoreModel.Instance.GetTemporal(kind, efProperty.IsNullable);
}
}
示例2: GetPrimitiveTypeReference
private static IEdmPrimitiveTypeReference GetPrimitiveTypeReference(
IProperty efProperty)
{
var kind = EdmPrimitiveTypeKind.None;
var propertyType = TypeHelper.GetUnderlyingTypeOrSelf(efProperty.ClrType);
if (!primitiveTypeKindMap.TryGetValue(propertyType, out kind))
{
return null;
}
if (TypeHelper.IsDateTime(propertyType))
{
RelationalPropertyAnnotations annotations = new RelationalPropertyAnnotations(efProperty, null);
var columnType = annotations.ColumnType;
if (string.Equals(columnType, "date", StringComparison.OrdinalIgnoreCase))
{
kind = EdmPrimitiveTypeKind.Date;
}
}
else if (TypeHelper.IsTimeSpan(propertyType))
{
RelationalPropertyAnnotations annotations = new RelationalPropertyAnnotations(efProperty, null);
var columnType = annotations.ColumnType;
if (string.Equals(columnType, "time", StringComparison.OrdinalIgnoreCase))
{
kind = EdmPrimitiveTypeKind.TimeOfDay;
}
}
switch (kind)
{
default:
return EdmCoreModel.Instance.GetPrimitive(kind, efProperty.IsNullable);
case EdmPrimitiveTypeKind.Binary:
return EdmCoreModel.Instance.GetBinary(
efProperty.GetMaxLength() < 0,
efProperty.GetMaxLength(),
efProperty.IsNullable);
case EdmPrimitiveTypeKind.Decimal:
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
////return EdmCoreModel.Instance.GetDecimal(
//// efProperty.Precision, efProperty.Scale,
//// efProperty.Nullable);
return EdmCoreModel.Instance.GetDecimal(efProperty.IsNullable);
case EdmPrimitiveTypeKind.String:
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
return EdmCoreModel.Instance.GetString(
efProperty.GetMaxLength() < 0,
efProperty.GetMaxLength(),
null,
efProperty.IsNullable);
case EdmPrimitiveTypeKind.DateTimeOffset:
case EdmPrimitiveTypeKind.Duration:
// TODO GitHubIssue#57: Complete EF7 to EDM model mapping
////return EdmCoreModel.Instance.GetTemporal(
//// kind, efProperty.Precision, efProperty.Nullable);
return EdmCoreModel.Instance.GetTemporal(kind, efProperty.IsNullable);
}
}
示例3: FindCustomMapping
protected override RelationalTypeMapping FindCustomMapping(IProperty property, bool unicode = true)
=> property.ClrType == typeof(string) && property.GetMaxLength().HasValue
? new RelationalTypeMapping((unicode ? "nvarchar(" : "varchar(") + property.GetMaxLength() + ")", typeof(string))
: base.FindCustomMapping(property, unicode);
示例4: FindCustomMapping
protected override RelationalTypeMapping FindCustomMapping(IProperty property)
=> property.ClrType == typeof(string) && property.GetMaxLength().HasValue
? new RelationalTypeMapping("nvarchar(" + property.GetMaxLength() + ")", typeof(string), dbType: null, unicode: true, size: property.GetMaxLength())
: base.FindCustomMapping(property);