public MappingModificationFunctionMapping(EditingContext context, ModificationFunction functionMapping, MappingEFElement parent) : base(context, functionMapping, parent) { if (functionMapping != null) { _functionType = functionMapping.FunctionType; _properties = new MappingFunctionScalarProperties(context, functionMapping, this); _resultBindings = new MappingResultBindings(context, functionMapping, this); } }
/// <summary> /// Creates a function mapping element for the passed in Function, inside an EntityTypeMapping /// for the passed in entity. /// </summary> /// <param name="conceptualEntityType"></param> /// <param name="function"></param> /// <param name="rowsAffectedParameter">Optional string argument</param> /// <param name="type"></param> internal CreateFunctionMappingCommand( EntityType conceptualEntityType, Function function, Parameter rowsAffectedParameter, ModificationFunctionType type) { Debug.Assert(type != ModificationFunctionType.None, "You cannot pass the None type"); CommandValidation.ValidateConceptualEntityType(conceptualEntityType); CommandValidation.ValidateFunction(function); _conceptualEntityType = conceptualEntityType; _function = function; _type = type; _rowsAffectedParameter = rowsAffectedParameter; }
internal static DeleteEFElementCommand GetDeleteCommand( EntityType conceptualEntityType, Function function, ModificationFunctionType type) { var cmd = new DeleteFunctionMappingCommand(conceptualEntityType, function, type); if (cmd == null) { // shouldn't happen, just to be safe throw new InvalidOperationException(); } return(cmd); }
/// <summary> /// Creates a ResultBinding element that maps the passed in Property to the result column, inside /// an EntityTypeMapping for the passed in entity. The Function is used to locate the correct /// ModificationFunction to house this. /// </summary> /// <param name="conceptualEntityType"></param> /// <param name="function"></param> /// <param name="entityProperty">Optional</param> /// <param name="columnName">Optional</param> internal CreateResultBindingCommand( EntityType conceptualEntityType, Function function, ModificationFunctionType functionType, Property entityProperty, string columnName) { CommandValidation.ValidateConceptualEntityType(conceptualEntityType); CommandValidation.ValidateFunction(function); Debug.Assert(functionType != ModificationFunctionType.None, "You cannot pass the None type"); _conceptualEntityType = conceptualEntityType; _function = function; _functionType = functionType; _entityProperty = entityProperty; _columnName = columnName; }
/// <summary> /// Delete a function mapping. The function mapping is located using the passed in EntityType to validate /// the EntityTypeMapping and then the Function to locate the mapping itself. /// </summary> /// <param name="conceptualEntityType"></param> /// <param name="function"></param> /// <param name="type"></param> internal DeleteFunctionMappingCommand(EntityType conceptualEntityType, Function function, ModificationFunctionType type) : base((EFElement)null) { CommandValidation.ValidateConceptualEntityType(conceptualEntityType); CommandValidation.ValidateFunction(function); foreach (var mf in function.GetAntiDependenciesOfType<ModificationFunction>()) { if (mf.ModificationFunctionMapping.EntityTypeMapping.FirstBoundConceptualEntityType == conceptualEntityType && mf.FunctionType == type) { EFElement = mf; break; } } // don't throw now in the c'tor Debug.Assert(ModificationFunction != null, "Couldn't find the ModificationFunction needed to complete this operation"); }
internal static ModificationFunction GetModificationFunction( EntityType conceptualEntityType, Function function, ModificationFunctionType type) { if (null == function || null == conceptualEntityType) { Debug.Assert(null != function, typeof(ModificationFunction).Name + ".GetModificationFunction() requires non-null function"); Debug.Assert( null != conceptualEntityType, typeof(ModificationFunction).Name + ".GetModificationFunction() requires non-null conceptualEntityType"); return(null); } foreach (var mf in function.GetAntiDependenciesOfType <ModificationFunction>()) { if (mf.ModificationFunctionMapping.EntityTypeMapping.FirstBoundConceptualEntityType == conceptualEntityType && mf.FunctionType == type) { return(mf); } } return(null); }
/// <summary> /// Delete a function mapping. The function mapping is located using the passed in EntityType to validate /// the EntityTypeMapping and then the Function to locate the mapping itself. /// </summary> /// <param name="conceptualEntityType"></param> /// <param name="function"></param> /// <param name="type"></param> internal DeleteFunctionMappingCommand(EntityType conceptualEntityType, Function function, ModificationFunctionType type) : base((EFElement)null) { CommandValidation.ValidateConceptualEntityType(conceptualEntityType); CommandValidation.ValidateFunction(function); foreach (var mf in function.GetAntiDependenciesOfType <ModificationFunction>()) { if (mf.ModificationFunctionMapping.EntityTypeMapping.FirstBoundConceptualEntityType == conceptualEntityType && mf.FunctionType == type) { EFElement = mf; break; } } // don't throw now in the c'tor Debug.Assert(ModificationFunction != null, "Couldn't find the ModificationFunction needed to complete this operation"); }
internal static ModificationFunction GetModificationFunction( EntityType conceptualEntityType, Function function, ModificationFunctionType type) { if (null == function || null == conceptualEntityType) { Debug.Assert(null != function, typeof(ModificationFunction).Name + ".GetModificationFunction() requires non-null function"); Debug.Assert( null != conceptualEntityType, typeof(ModificationFunction).Name + ".GetModificationFunction() requires non-null conceptualEntityType"); return null; } foreach (var mf in function.GetAntiDependenciesOfType<ModificationFunction>()) { if (mf.ModificationFunctionMapping.EntityTypeMapping.FirstBoundConceptualEntityType == conceptualEntityType && mf.FunctionType == type) { return mf; } } return null; }
internal static DeleteEFElementCommand GetDeleteCommand( EntityType conceptualEntityType, Function function, ModificationFunctionType type) { var cmd = new DeleteFunctionMappingCommand(conceptualEntityType, function, type); if (cmd == null) { // shouldn't happen, just to be safe throw new InvalidOperationException(); } return cmd; }