/// <summary> /// Overridden to allow the addition of buddy-class attributes to the list of attributes associated with the <see cref="ModelType"/> /// </summary> /// <param name="declaringType"></param> /// <param name="property"></param> /// <param name="name"></param> /// <param name="isStatic"></param> /// <param name="isBoundary"></param> /// <param name="propertyType"></param> /// <param name="isList"></param> /// <param name="attributes"></param> /// <returns></returns> protected override ModelValueProperty CreateValueProperty(ModelType declaringType, System.Reflection.PropertyInfo property, string name, string label, string helptext, string format, bool isStatic, Type propertyType, TypeConverter converter, bool isList, bool isReadOnly, bool isPersisted, Attribute[] attributes) { // Do not include entity reference properties in the model if (property.PropertyType.IsSubclassOf(typeof(EntityReference))) return null; // Fetch any attributes associated with a buddy-class attributes = attributes.Union(GetBuddyClassAttributes(declaringType, property)).ToArray(); // Mark properties that are not mapped as not persisted isPersisted = !attributes.OfType<NotMappedAttribute>().Any(); return new EntityValueProperty(declaringType, property, name, label, helptext, format, isStatic, propertyType, converter, isList, isReadOnly, isPersisted, attributes); }
/// <summary> /// Overridden to allow the addition of buddy-class attributes to the list of attributes associated with the <see cref="ModelType"/> /// </summary> /// <param name="declaringType"></param> /// <param name="property"></param> /// <param name="name"></param> /// <param name="isStatic"></param> /// <param name="isBoundary"></param> /// <param name="propertyType"></param> /// <param name="isList"></param> /// <param name="attributes"></param> /// <returns></returns> protected override ModelReferenceProperty CreateReferenceProperty(ModelType declaringType, System.Reflection.PropertyInfo property, string name, string label, string helptext, string format, bool isStatic, ModelType propertyType, bool isList, bool isReadOnly, bool isPersisted, Attribute[] attributes) { // Fetch any attributes associated with a buddy-class attributes = attributes.Union(GetBuddyClassAttributes(declaringType, property)).ToArray(); // Mark properties that are not mapped as not persisted isPersisted = !attributes.OfType<NotMappedAttribute>().Any(); // Determine whether the property represents an actual entity framework navigation property or an custom property var context = GetObjectContext(); var type = context.ObjectContext.MetadataWorkspace.GetItem<EntityType>(((EntityModelType)declaringType).UnderlyingType.FullName, DataSpace.CSpace); NavigationProperty navProp; type.NavigationProperties.TryGetValue(name, false, out navProp); return new EntityReferenceProperty(declaringType, navProp, property, name, label, helptext, format, isStatic, propertyType, isList, isReadOnly, isPersisted, attributes); }