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); }
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); }); } }