internal override bool ParseSingleElement(ICollection <XName> unprocessedElements, XElement elem) { // EntityContainer elements are treated differently depending // whether we are in an SSDL EntityModel or a CSDL EntityModel // so do not include here if (elem.Name.LocalName == EntityType.ElementName) { EntityType et = null; if (IsCSDL) { et = new ConceptualEntityType(this as ConceptualEntityModel, elem); } else { et = new StorageEntityType(this as StorageEntityModel, elem); } _entityTypes.Add(et); et.Parse(unprocessedElements); } else if (elem.Name.LocalName == Association.ElementName) { var assoc = new Association(this, elem); _associations.Add(assoc); assoc.Parse(unprocessedElements); } else { return(base.ParseSingleElement(unprocessedElements, elem)); } return(true); }
internal AssociationSetEndMappingBuilder(AssociationSetEnd setEnd, StorageEntityType storageEntityType) { Debug.Assert(setEnd != null, "setEnd should not be null"); Debug.Assert(storageEntityType != null, "storageEntityType should not be null"); _setEnd = setEnd; _storageEntityType = storageEntityType; }
protected override void InvokeInternal(CommandProcessorContext cpc) { var service = cpc.EditingContext.GetEFArtifactService(); var artifact = service.Artifact; // the model that we want to add the entity to var model = ModelHelper.GetEntityModel(artifact, ModelSpaceValue); if (model == null) { throw new CannotLocateParentItemException(); } // check for uniqueness if (UniquifyName) { Name = ModelHelper.GetUniqueName(typeof(EntityType), model, Name); } else { string msg = null; if (ModelHelper.IsUniqueName(typeof(EntityType), model, Name, false, out msg) == false) { throw new CommandValidationFailedException(msg); } } // create the new item in our model EntityType entity = null; if (model.IsCSDL) { entity = new ConceptualEntityType(model as ConceptualEntityModel, null); } else { entity = new StorageEntityType(model as StorageEntityModel, null); } Debug.Assert(entity != null, "entity should not be null"); if (entity == null) { throw new ItemCreationFailureException(); } // set the name, add it to the parent item entity.LocalName.Value = Name; model.AddEntityType(entity); XmlModelHelper.NormalizeAndResolve(entity); CreatedEntityType = entity; }
internal AssociationSetEndMappingBuilderForViewModel( AssociationSetEnd setEnd, StorageEntityType storeEntityType, MappingAssociationSetEnd mase) : base(setEnd, storeEntityType) { _mase = mase; }
internal AssociationSetEndMappingBuilderForCommand(AssociationSetEnd setEnd, StorageEntityType storeEntityType) : base(setEnd, storeEntityType) { }
/// <summary> /// A helper method that creates the AssociationSetMapping and also tries to "Intelli-Match" some mappings, that is, if there are /// columns and properties that match by name, we create mappings for the user. /// </summary> /// <param name="cpc"></param> /// <param name="association"></param> /// <param name="storageEntityType"></param> /// <returns></returns> internal static AssociationSetMapping CreateAssociationSetMappingAndIntellimatch( CommandProcessorContext cpc, Association association, StorageEntityType storageEntityType) { var associationSet = association.AssociationSet; Debug.Assert(associationSet != null, "An association found that doesn't have an association set"); var cmd = new CreateAssociationSetMappingCommand(association, storageEntityType); CommandProcessor.InvokeSingleCommand(cpc, cmd); foreach (var setEnd in associationSet.AssociationSetEnds()) { var builder = new AssociationSetEndMappingBuilderForCommand(setEnd, storageEntityType); builder.Build(cpc); } return cmd.AssociationSetMapping; }
internal StorageProperty(StorageEntityType parent, XElement element) : base(parent, element) { }
/// <summary> /// Creates a new property in the passed in storage entity and optionally sets additional /// facets on the property. /// NOTE: If the cpc already has an active transaction, these changes will be in that transaction /// and the caller of this helper method must commit it to see these changes commited. /// </summary> /// <param name="cpc"></param> /// <param name="name">The name of the property</param> /// <param name="entityType">Must be a storage entity</param> /// <param name="type">The type to use for this property (cannot be empty)</param> /// <param name="nullable">Flag whether the property is nullable or not</param> /// <param name="theDefault">Optional: the default value for this property</param> /// <param name="maxLength">Optional facet</param> /// <param name="fixedLength">Optional facet</param> /// <param name="precision">Optional facet</param> /// <param name="scale">Optional facet</param> /// <param name="unicode">Optional facet</param> /// <param name="collation">Optional facet</param> /// <param name="concurrencyMode">Optional: the concurrency mode for this property</param> /// <returns>The new Property</returns> internal static Property CreateStorageProperty( CommandProcessorContext cpc, string name, StorageEntityType entityType, string type, bool? nullable, StringOrNone theDefault, StringOrPrimitive<UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive<UInt32> precision, StringOrPrimitive<UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode) { CommandValidation.ValidateStorageEntityType(entityType); var cpcd = new CreatePropertyCommand(name, entityType, type, nullable); var ssp = new SetPropertyFacetsCommand( cpcd, theDefault, maxLength, fixedLength, precision, scale, unicode, collation, concurrencyMode); var cp = new CommandProcessor(cpc, cpcd, ssp); cp.Invoke(); return cpcd.CreatedProperty; }
private static Property CreateStorageProperty(StorageEntityType parentEntity, string name, string type) { var property = new StorageProperty(parentEntity, null); property.LocalName.Value = name; property.Type.Value = type; return property; }
private static StorageEntityType FindMatchingStorageEntityTypeInExistingArtifact( StorageEntityType entityTypeFromTempArtifact) { if (null == entityTypeFromTempArtifact) { Debug.Fail("Null entityTypeFromTempArtifact"); return null; } // if the EntityType is S-side then (since we have already replaced the SSDL) // it is safe to match just by name Debug.Assert(entityTypeFromTempArtifact.EntityModel is BaseEntityModel, "EntityModel should be a BaseEntityModel"); Debug.Assert(!entityTypeFromTempArtifact.EntityModel.IsCSDL, "StorageEntityType is from CSDL? This is wrong!"); var et = ModelHelper.FindEntityType(entityTypeFromTempArtifact.EntityModel, entityTypeFromTempArtifact.LocalName.Value); var set = et as StorageEntityType; Debug.Assert(null != set, "Matching EntityType from temp artifact is not a StorageEntityType"); return set; }