/// <summary> /// This helper function is an easy way to get a new entity type, entity set and key property in the /// new entity type created in the conceptual or storage model. /// 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 new entity</param> /// <param name="setName">The name of the new set</param> /// <param name="createKeyProperty">A flag whether to create a new key property or not (sending false creates no new property)</param> /// <param name="propertyName">The name of the new property</param> /// <param name="propertyType">The type of the new property</param> /// <param name="modelSpace">Either Conceptual or Storage</param> /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param> /// <param name="isDefaultName">Flag whether the name is the default for new entity types/sets</param> /// <returns>The new EntityType</returns> internal static EntityType CreateEntityTypeAndEntitySetAndProperty( CommandProcessorContext cpc, string name, string setName, bool createKeyProperty, string propertyName, string propertyType, string propertyStoreGeneratedPattern, ModelSpace modelSpace, bool uniquifyNames, bool isDefaultName = false) { var cp = new CommandProcessor(cpc); var cet = new CreateEntityTypeCommand(name, modelSpace, uniquifyNames); cet.CreateWithDefaultName = isDefaultName; cp.EnqueueCommand(cet); var ces = new CreateEntitySetCommand(setName, cet, modelSpace, uniquifyNames); cp.EnqueueCommand(ces); if (createKeyProperty) { var cpcd = new CreatePropertyCommand(propertyName, cet, propertyType, false); cpcd.IsIdProperty = true; cp.EnqueueCommand(cpcd); var skpc = new SetKeyPropertyCommand(cpcd, true); cp.EnqueueCommand(skpc); var ssgpc = new SetStoreGeneratedPatternCommand(cpcd, propertyStoreGeneratedPattern); cp.EnqueueCommand(ssgpc); } cp.Invoke(); return(cet.EntityType); }
/// <summary> /// This helper function is an easy way to get a new entity type, entity set and key property in the /// new entity type created in the conceptual or storage model. /// 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 new entity</param> /// <param name="setName">The name of the new set</param> /// <param name="createKeyProperty">A flag whether to create a new key property or not (sending false creates no new property)</param> /// <param name="propertyName">The name of the new property</param> /// <param name="propertyType">The type of the new property</param> /// <param name="modelSpace">Either Conceptual or Storage</param> /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param> /// <param name="isDefaultName">Flag whether the name is the default for new entity types/sets</param> /// <returns>The new EntityType</returns> internal static EntityType CreateEntityTypeAndEntitySetAndProperty( CommandProcessorContext cpc, string name, string setName, bool createKeyProperty, string propertyName, string propertyType, string propertyStoreGeneratedPattern, ModelSpace modelSpace, bool uniquifyNames, bool isDefaultName = false) { var cp = new CommandProcessor(cpc); var cet = new CreateEntityTypeCommand(name, modelSpace, uniquifyNames); cet.CreateWithDefaultName = isDefaultName; cp.EnqueueCommand(cet); var ces = new CreateEntitySetCommand(setName, cet, modelSpace, uniquifyNames); cp.EnqueueCommand(ces); if (createKeyProperty) { var cpcd = new CreatePropertyCommand(propertyName, cet, propertyType, false); cpcd.IsIdProperty = true; cp.EnqueueCommand(cpcd); var skpc = new SetKeyPropertyCommand(cpcd, true); cp.EnqueueCommand(skpc); var ssgpc = new SetStoreGeneratedPatternCommand(cpcd, propertyStoreGeneratedPattern); cp.EnqueueCommand(ssgpc); } cp.Invoke(); return cet.EntityType; }