How to extract only stored procedures from metadata?

Guys, is there a way to retrieve only stored procedures from the storage model (SSDL) in MetadataWorkspace?

I am currently using the following code to retrieve stored procedures from MetadataWorkspace (I am checking the built-in attribute of the EdmFunction object):

public static List<EdmFunction> TryGetSsdlFunctions( this MetadataWorkspace metadataWorkspace )
{
    List<EdmFunction> functions = new List<EdmFunction>();

    foreach ( EdmFunction function in metadataWorkspace.GetItems<EdmFunction>( DataSpace.SSpace ) )
    {
        MetadataProperty builtInAttribute = function.MetadataProperties.FirstOrDefault( p => p.Name == "BuiltInAttribute" );
        if ( builtInAttribute != null && Convert.ToBoolean( builtInAttribute.Value.ToString() ) == false )
        {
            functions.Add( function );
        }
    }

    return functions;
}

The problem is that in addition to stored procedures, this will return all the functions included in the data model. And I want only stored procedures. I see that there are differences in the value of the IsComposable attribute, but I'm not sure if this is a reliable criterion.

Thanks in advance.

ps: If you think there is a more reasonable way to extract stored procedures from the workspace, share it.

+3
2

?

public static List<EdmFunction> TryGetSsdlFunctions( this MetadataWorkspace metadataWorkspace ) { 
  List<EdmFunction> functions = (from func in metadataWorkspace.GetItems<EdmFunction>(DataSpace.SSpace) )
                                where func.ReturnParameter == null
                                select func).ToList();
  return functions;
}
+1

. IsComposable , EdmFunction .

EdmFunction.IsComposableAttribute

, .

: System.Boolean

true, ; false, .

.NET Framework

4.5

https://msdn.microsoft.com/en-us/library/system.data.metadata.edm.edmfunction.iscomposableattribute(v=vs.110).aspx

( , , Google, . , - .)

0

Source: https://habr.com/ru/post/1793919/


All Articles