Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
            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();
            }
Ejemplo n.º 3
0
            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();
            }
Ejemplo n.º 4
0
        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;
        }