Ejemplo n.º 1
0
        private DataProperty CreateDataProperty(StructuralType structuralType, PropertyInfo pInfo)
        {
            var propType = pInfo.PropertyType;
            var dp       = new DataProperty(pInfo.Name);

            // TODO: handle isScalar
            if (typeof(IComplexObject).IsAssignableFrom(propType))
            {
                dp.ComplexType = MetadataStore.GetComplexType(propType);
                dp.IsNullable  = false;
                // complex Objects do not have defaultValues currently
            }
            else
            {
                var nnType = TypeFns.GetNonNullableType(propType);
                dp.ClrType = propType;

                dp.DataType     = DataType.FromClrType(nnType);
                dp.IsNullable   = TypeFns.IsNullableType(propType);
                dp.DefaultValue = dp.IsNullable ? null : dp.DataType.DefaultValue;
                var isEnumType = nnType.GetTypeInfo().IsEnum;
                if (isEnumType)
                {
                    dp.EnumTypeName = nnType.FullName;
                }
            }

            structuralType.AddDataProperty(dp);
            return(dp);
        }
Ejemplo n.º 2
0
 private static void UpdateBaseProperties(StructuralType structuralType, StructuralType baseStructuralType)
 {
     baseStructuralType.DataProperties.ForEach(dp => {
         var newDp = new DataProperty(dp);
         structuralType.AddDataProperty(newDp);
     });
     if (baseStructuralType.IsEntityType)
     {
         var entityType     = (EntityType)structuralType;
         var baseEntityType = (EntityType)baseStructuralType;
         baseEntityType.NavigationProperties.ForEach(np => {
             var newNp = new NavigationProperty(np);
             entityType.AddNavigationProperty(newNp);
         });
     }
 }