private Type ResolveType(ModuleBuilder moduleBuilder, EntityPropertyElement propertyElement) { var propertyType = propertyElement.PropertyType; Type resolvedType; if (propertyType.TypeKind == StructuralModelTypeKind.Primitive) { resolvedType = ConvertType(((PrimitiveTypeElement)propertyType).PrimitiveType); } else if (propertyType.TypeKind == StructuralModelTypeKind.Enum) { if (!_typesById.TryGetValue(propertyType.Identity, out resolvedType)) { _typesById.Add(propertyType.Identity, resolvedType = CreateEnum(moduleBuilder, (EnumTypeElement)propertyType)); } } else { throw new NotSupportedException(); } if (propertyElement.IsNullable && resolvedType.IsValueType) { return(typeof(Nullable <>).MakeGenericType(resolvedType)); } return(resolvedType); }
private IEdmTypeReference BuildPropertyType(EntityPropertyElement propertyElement) { var propertyType = propertyElement.PropertyType; var primitiveType = propertyType as PrimitiveTypeElement; if (primitiveType != null) { return(EdmCoreModel.Instance.GetPrimitive(Convert(primitiveType.PrimitiveType), propertyElement.IsNullable)); } var enumType = propertyType as EnumTypeElement; if (enumType != null) { return(new EdmEnumTypeReference(BuildEnumType(enumType), propertyElement.IsNullable)); } throw new NotSupportedException(); }
private IEdmTypeReference ResolveTypeReference(EntityPropertyElement propertyElement) { var propertyType = propertyElement.PropertyType; var primitiveType = propertyType as PrimitiveTypeElement; if (primitiveType != null) { return EdmCoreModel.Instance.GetPrimitive(Convert(primitiveType.PrimitiveType), propertyElement.IsNullable); } var enumType = propertyType as EnumTypeElement; if (enumType != null) { return new EdmEnumTypeReference(ResolveEnumType(enumType), propertyElement.IsNullable); } throw new NotSupportedException(); }
private Type ResolveType(ModuleBuilder moduleBuilder, EntityPropertyElement propertyElement) { var propertyType = propertyElement.PropertyType; Type resolvedType; if (propertyType.TypeKind == StructuralModelTypeKind.Primitive) { resolvedType = ConvertType(((PrimitiveTypeElement)propertyType).PrimitiveType); } else if (propertyType.TypeKind == StructuralModelTypeKind.Enum) { if (!_typesById.TryGetValue(propertyType.Identity, out resolvedType)) { _typesById.Add(propertyType.Identity, resolvedType = CreateEnum(moduleBuilder, (EnumTypeElement)propertyType)); } } else { throw new NotSupportedException(); } if (propertyElement.IsNullable && resolvedType.IsValueType) { return typeof(Nullable<>).MakeGenericType(resolvedType); } return resolvedType; }