【发布时间】:2012-01-27 21:34:39
【问题描述】:
假设我已经构建了 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?
}
}
}
}
【问题讨论】:
-
你为什么要为此使用反射?
标签: c# .net entity-framework reflection stored-procedures