1
考虑我已经构建了DAL.dll,它是一个包含实体框架edmx的类库。在Designer.cs,进口下列存储过程定义:使用反射从实体数据模型获取存储过程名称。
<Function Name="Login_User" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="Login_Name" Type="nvarchar" Mode="In" />
<Parameter Name="Password" Type="nvarchar" Mode="In" />
<Parameter Name="SP_Return_Code" Type="int" Mode="InOut" />
</Function>
下面我已经使用反射来找到TYPE1作为ObjectContext的类型。如何通过反映type1来发现Login_User存储过程?
private static void ReflectionTest()
{
var asm = Assembly.LoadFrom(@"C:\DAL.dll");
// list stored procedure calls
foreach (var type in asm.GetTypes())
{
if (type.BaseType == typeof(ObjectContext))
{
foreach (var type1 in type.GetMethods())
{
// how do I reflect against type1 for its stored procedure names?
}
}
}
}
? – 2012-01-28 10:48:00