internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == Property.ElementName) { Property prop; var conceptualModel = (ConceptualEntityModel)GetParentOfType(typeof(ConceptualEntityModel)); Debug.Assert( conceptualModel != null, typeof(ComplexType).Name + "ParseSingleElement: Unable to find parent of type ConceptualEntityModel"); if (conceptualModel != null && ModelHelper.IsElementComplexProperty(elem, conceptualModel)) { prop = new ComplexConceptualProperty(this, elem); } else { prop = new ConceptualProperty(this, elem); } prop.Parse(unprocessedElements); AddProperty(prop); } else { return(base.ParseSingleElement(unprocessedElements, elem)); } return(true); }
protected override void ProcessPreReqCommands() { if (_property == null) { var prereq = GetPreReqCommand(CreatePropertyCommand.PrereqId) as CreatePropertyCommand; Debug.Assert(null != prereq, "Pre-req CreatePropertyCommand is not present for PrereqId " + CreatePropertyCommand.PrereqId); if (null != prereq) { var prop = prereq.CreatedProperty; Debug.Assert(null != prop, "Pre-req Command returned null Property"); if (null != prop) { _property = prop as ConceptualProperty; Debug.Assert( null != _property, "Pre-req Command returned Property of type " + prop.GetType().FullName + ". Should be ConceptualProperty"); } } } }
/// <summary> /// returns list of StorageProperties mapped to a ConceptualProperty via an EntitySetMapping /// or an EntityTypeMapping /// </summary> /// <param name="cProp"></param> /// <returns></returns> private static IEnumerable<StorageProperty> MappedStorageProperties(ConceptualProperty cProp) { Debug.Assert(null != cProp, "null ConceptualProperty"); if (null != cProp) { // loop over ConceptualProperties mapped to this ConceptualProperty foreach (var sp in cProp.GetAntiDependenciesOfType<ScalarProperty>()) { // only use ScalarProperty elements inside an EntitySetMapping or EntityTypeMapping // (MappingFragment is only used by those types of mappings) if (null != sp.GetParentOfType(typeof(MappingFragment))) { var sProp = sp.ColumnName.Target as StorageProperty; if (null != sProp) { yield return sProp; } } } } }
// add one PropagateConceptualSGPToStorageProperty for each StorageProperty mapped to this ConceptualProperty internal static void AddRule(CommandProcessorContext cpc, ConceptualProperty cProp, bool propagateNoneSGP) { if (null != cProp) { foreach (var sProp in MappedStorageProperties(cProp)) { IIntegrityCheck check = new PropagateStoreGeneratedPatternToStorageModel(cpc, sProp, propagateNoneSGP); cpc.AddIntegrityCheck(check); } } }
protected override void InvokeInternal(CommandProcessorContext cpc) { // safety check, this should never be hit Debug.Assert(ParentComplexType != null, "InvokeInternal is called when ParentComplexType is null."); if (ParentComplexType == null) { throw new InvalidOperationException("InvokeInternal is called when ParentComplexType is null"); } Debug.Assert(!(Type == null && ComplexType == null), "InvokeInternal is called when Type or ComplexType is null."); if (Type == null && ComplexType == null) { throw new InvalidOperationException("InvokeInternal is called when Type and ComplexType is null"); } // check for uniqueness string msg; if (!ModelHelper.ValidateComplexTypePropertyName(ParentComplexType, Name, true, out msg)) { throw new CommandValidationFailedException(msg); } // check for ComplexType circular definition if (ComplexType != null) { if (ModelHelper.ContainsCircularComplexTypeDefinition(ParentComplexType, ComplexType)) { throw new CommandValidationFailedException( String.Format( CultureInfo.CurrentCulture, Resources.Error_CircularComplexTypeDefinitionOnAdd, ComplexType.LocalName.Value)); } } // create the property Property property = null; if (Type != null) { var conceptualProperty = new ConceptualProperty(ParentComplexType, null); conceptualProperty.ChangePropertyType(Type); property = conceptualProperty; } else { var complexProperty = new ComplexConceptualProperty(ParentComplexType, null); complexProperty.ComplexType.SetRefName(ComplexType); property = complexProperty; } Debug.Assert(property != null, "property should not be null"); if (property == null) { throw new ItemCreationFailureException(); } // set the name and add to the parent entity property.LocalName.Value = Name; ParentComplexType.AddProperty(property); // set other attributes of the property if (Nullable != null) { property.Nullable.Value = (Nullable.Value ? BoolOrNone.TrueValue : BoolOrNone.FalseValue); } XmlModelHelper.NormalizeAndResolve(property); _createdProperty = property; }
internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == Property.ElementName) { Property prop; var conceptualModel = (ConceptualEntityModel)GetParentOfType(typeof(ConceptualEntityModel)); Debug.Assert( conceptualModel != null, typeof(ComplexType).Name + "ParseSingleElement: Unable to find parent of type ConceptualEntityModel"); if (conceptualModel != null && ModelHelper.IsElementComplexProperty(elem, conceptualModel)) { prop = new ComplexConceptualProperty(this, elem); } else { prop = new ConceptualProperty(this, elem); } prop.Parse(unprocessedElements); AddProperty(prop); } else { return base.ParseSingleElement(unprocessedElements, elem); } return true; }
private static Property CreateConceptualProperty(ConceptualEntityType parentEntity, string name, string type, InsertPropertyPosition insertPosition) { var property = new ConceptualProperty(parentEntity, null, insertPosition); property.LocalName.Value = name; property.ChangePropertyType(type); return property; }