samples/Provider/SampleEntityFrameworkProvider/SqlGeneration/SqlGenerator.cs
/// <summary>
/// Translate a function command tree to a SQL string.
/// </summary>
Translate a function command tree to a SQL string.
Translate a function command tree to a SQL string .
private string GenerateFunctionSql(DbFunctionCommandTree tree, out CommandType commandType)
        {
            EdmFunction function = tree.EdmFunction;
            string userCommandText = (string)function.MetadataProperties["CommandTextAttribute"].Value;
            string userSchemaName = (string)function.MetadataProperties["Schema"].Value;
            string userFuncName = (string)function.MetadataProperties["StoreFunctionNameAttribute"].Value;
            if (String.IsNullOrEmpty(userCommandText))
            {
                commandType = CommandType.StoredProcedure;
                string schemaName = String.IsNullOrEmpty(userSchemaName) ?
                    function.NamespaceName : userSchemaName;
                string functionName = String.IsNullOrEmpty(userFuncName) ?
                    function.Name : userFuncName;
                string quotedSchemaName = QuoteIdentifier(schemaName);
                string quotedFunctionName = QuoteIdentifier(functionName);
                const string schemaSeparator = ".";
                string quotedFunctionText = quotedSchemaName + schemaSeparator + quotedFunctionName;
                return quotedFunctionText;
            }
            else
            {
                commandType = CommandType.Text;
                return userCommandText;
            }
        }
private string GenerateFunctionSql ( DbFunctionCommandTree tree , out CommandType commandType ) { EdmFunction function = tree . EdmFunction ; string userCommandText = ( string ) function . MetadataProperties [ " " ] . Value ; string userSchemaName = ( string ) function . MetadataProperties [ " " ] . Value ; string userFuncName = ( string ) function . MetadataProperties [ " " ] . Value ; if ( String . IsNullOrEmpty ( userCommandText ) ) { commandType = CommandType . StoredProcedure ; string schemaName = String . IsNullOrEmpty ( userSchemaName ) ? function . NamespaceName : userSchemaName ; string functionName = String . IsNullOrEmpty ( userFuncName ) ? function . Name : userFuncName ; string quotedSchemaName = QuoteIdentifier ( schemaName ) ; string quotedFunctionName = QuoteIdentifier ( functionName ) ; const string schemaSeparator = " " ; string quotedFunctionText = quotedSchemaName + schemaSeparator + quotedFunctionName ; return quotedFunctionText ; } else { commandType = CommandType . Text ; return userCommandText ; } }
Translate a function command tree to a SQL string.
Translate a function command tree to a SQL string .
// We expect function to always have these properties // build a quoted description of the function // if the schema name is not explicitly given, it is assumed to be the metadata namespace // if the function store name is not explicitly given, it is assumed to be the metadata name // quote elements of function text // separator // concatenate elements of function text // if the user has specified the command text, pass it through verbatim and choose CommandType.Text
tree
DbFunctionCommandTree
CommandType
out