protected override void OnChildDeleted(EFContainer efContainer) { var child = efContainer as DefiningQuery; if (child != null) { _definingQuery = null; return; } base.OnChildDeleted(efContainer); }
protected override void PreParse() { Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state"); ClearEFObject(_definingQuery); _definingQuery = null; ClearEFObject(_schemaAttr); _schemaAttr = null; ClearEFObject(_tableAttr); _tableAttr = null; ClearEFObject(_storeSchemaGenTypeAttr); _storeSchemaGenTypeAttr = null; ClearEFObject(_storeSchemaGenSchemaAttr); _storeSchemaGenSchemaAttr = null; ClearEFObject(_storeSchemaGenNameAttr); _storeSchemaGenNameAttr = null; base.PreParse(); }
internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == DefiningQuery.ElementName) { if (_definingQuery != null) { // multiple DefiningQuery elements var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, elem.Name.LocalName); Artifact.AddParseErrorForObject(this, msg, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED); } else { _definingQuery = new DefiningQuery(this, elem); _definingQuery.Parse(unprocessedElements); } } else { return(base.ParseSingleElement(unprocessedElements, elem)); } return(true); }
protected override void InvokeInternal(CommandProcessorContext cpc) { Debug.Assert(EntityType != null, "InvokeInternal is called when EntityType is null"); if (EntityType == null) { throw new InvalidOperationException("InvokeInternal is called when EntityType is null"); } var service = cpc.EditingContext.GetEFArtifactService(); var artifact = service.Artifact; // locate the entity container we want to add it to BaseEntityContainer entityContainer = null; EntitySet entitySet = null; switch (ModelSpaceValue) { case ModelSpace.Conceptual: Debug.Assert(artifact.ConceptualModel() != null, "artifact.ConceptualModel() should not be null"); entityContainer = artifact.ConceptualModel().FirstEntityContainer; break; case ModelSpace.Storage: Debug.Assert(artifact.StorageModel() != null, "artifact.StorageModel() should not be null"); entityContainer = artifact.StorageModel().FirstEntityContainer; break; default: Debug.Fail("Unknown model space"); break; } Debug.Assert(entityContainer != null, "entityContainer should not be null"); if (entityContainer == null) { throw new CannotLocateParentItemException(); } // check for uniqueness of the name within the chosen EC if (UniquifyName) { Name = ModelHelper.GetUniqueName(typeof(EntitySet), entityContainer, Name); } else { string msg = null; if (ModelHelper.IsUniqueName(typeof(EntitySet), entityContainer, Name, false, out msg) == false) { throw new CommandValidationFailedException(msg); } } // create the entity set; don't need to assert on enum since that has happened above if (ModelSpaceValue == ModelSpace.Conceptual) { entitySet = new ConceptualEntitySet(entityContainer, null); } else { entitySet = new StorageEntitySet(entityContainer, null); // DefiningQuery creation if (DefiningQueryContent != null) { var definingQuery = new DefiningQuery(entitySet, null); definingQuery.XElement.SetValue(DefiningQueryContent); ((StorageEntitySet)entitySet).DefiningQuery = definingQuery; } } Debug.Assert(entitySet != null, "entitySet should not be null"); if (entitySet == null) { throw new ItemCreationFailureException(); } // set name and add to the parent entitySet.LocalName.Value = Name; entityContainer.AddEntitySet(entitySet); // set the entity type binding if (EntityType != null) { entitySet.EntityType.SetRefName(EntityType); } XmlModelHelper.NormalizeAndResolve(entitySet); EntitySet = entitySet; }