/// <summary> /// determines if an EdmFunction is an aggregate function /// </summary> /// <param name="function"></param> /// <returns></returns> internal static bool IsAggregateFunction(EdmFunction function) { return(function.AggregateAttribute); }
/// <summary> /// Convert the S type function parameters and returnType to C types. /// </summary> private EdmFunction ConvertFunctionSignatureToCType(EdmFunction sTypeFunction) { Debug.Assert(sTypeFunction.DataSpace == Edm.DataSpace.SSpace, "sTypeFunction.DataSpace == Edm.DataSpace.SSpace"); if (sTypeFunction.IsFromProviderManifest) { return(sTypeFunction); } FunctionParameter returnParameter = null; if (sTypeFunction.ReturnParameter != null) { TypeUsage edmTypeUsageReturnParameter = MetadataHelper.ConvertStoreTypeUsageToEdmTypeUsage(sTypeFunction.ReturnParameter.TypeUsage); returnParameter = new FunctionParameter( sTypeFunction.ReturnParameter.Name, edmTypeUsageReturnParameter, sTypeFunction.ReturnParameter.GetParameterMode()); } List <FunctionParameter> parameters = new List <FunctionParameter>(); if (sTypeFunction.Parameters.Count > 0) { foreach (var parameter in sTypeFunction.Parameters) { TypeUsage edmTypeUsage = MetadataHelper.ConvertStoreTypeUsageToEdmTypeUsage(parameter.TypeUsage); FunctionParameter edmTypeParameter = new FunctionParameter(parameter.Name, edmTypeUsage, parameter.GetParameterMode()); parameters.Add(edmTypeParameter); } } FunctionParameter[] returnParameters = returnParameter == null ? new FunctionParameter[0] : new FunctionParameter[] { returnParameter }; EdmFunction edmFunction = new EdmFunction(sTypeFunction.Name, sTypeFunction.NamespaceName, DataSpace.CSpace, new EdmFunctionPayload { Schema = sTypeFunction.Schema, StoreFunctionName = sTypeFunction.StoreFunctionNameAttribute, CommandText = sTypeFunction.CommandTextAttribute, IsAggregate = sTypeFunction.AggregateAttribute, IsBuiltIn = sTypeFunction.BuiltInAttribute, IsNiladic = sTypeFunction.NiladicFunctionAttribute, IsComposable = sTypeFunction.IsComposableAttribute, IsFromProviderManifest = sTypeFunction.IsFromProviderManifest, IsCachedStoreFunction = true, IsFunctionImport = sTypeFunction.IsFunctionImport, ReturnParameters = returnParameters, Parameters = parameters.ToArray(), ParameterTypeSemantics = sTypeFunction.ParameterTypeSemanticsAttribute, }); edmFunction.SetReadOnly(); return(edmFunction); }
internal EdmFunction ConvertToCTypeFunction(EdmFunction sTypeFunction) { return(this._cachedCTypeFunction.Evaluate(sTypeFunction)); }
/// <summary> /// Gets the function as specified by the function key. /// All parameters are assumed to be <see cref="ParameterMode.In"/>. /// </summary> /// <param name="functionName">Name of the function</param> /// <param name="parameterTypes">types of the parameters</param> /// <param name="ignoreCase">true for case-insensitive lookup</param> /// <param name="function">The function that needs to be returned</param> /// <returns> The function as specified in the function key or null</returns> /// <exception cref="System.ArgumentNullException">if functionName or parameterTypes argument is null</exception> /// <exception cref="System.ArgumentException">if no function is found with the given name or with given input parameters</exception> internal bool TryGetFunction(string functionName, TypeUsage[] parameterTypes, bool ignoreCase, out EdmFunction function) { EntityUtil.GenericCheckArgumentNull(functionName, "functionName"); EntityUtil.GenericCheckArgumentNull(parameterTypes, "parameterTypes"); string functionIdentity = EdmFunction.BuildIdentity(functionName, parameterTypes); GlobalItem item = null; function = null; if (TryGetValue(functionIdentity, ignoreCase, out item) && Helper.IsEdmFunction(item)) { function = (EdmFunction)item; return(true); } return(false); }
internal void AddFunctionImport(EdmFunction function) { Debug.Assert(function != null, "function != null"); Debug.Assert(function.IsFunctionImport, "function.IsFunctionImport"); _functionImports.Source.Add(function); }
/// <summary> /// Returns the function import in the target space, for the given entity container. /// </summary> internal bool TryGetFunctionImport(EntityContainer entityContainer, String functionImportName, bool ignoreCase, out EdmFunction functionImport) { // There are no entity containers in the OSpace. So there is no mapping involved. // Hence the name should be a valid name in the CSpace. functionImport = null; if (ignoreCase) { functionImport = entityContainer.FunctionImports.Where(fi => String.Equals(fi.Name, functionImportName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); } else { functionImport = entityContainer.FunctionImports.Where(fi => fi.Name == functionImportName).SingleOrDefault(); } return(functionImport != null); }