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