0

ブログ scottgu から Linq to sql を調べたところ、次のエラー メッセージが表示されました。

「シンボル ExecuteMethodCall を解決できません」。

メソッド ExecuteMethodCallis は linq to sql でサポートされていますが、なぜこのエラーが表示されるのですか?

ALTER PROCEDURE dbo.VariableShapeSample
        (
    @shape int 
    )

AS
    if(@shape=1)
    select * from products
    else if (@shape=2)
    select * from orders

public partial class NorthwindDataContext
{
    [Function(Name = "VariableShapeSample")]
    [ResultType(typeof (Product))]
    [ResultType(typeof (Order))]
    public IMultipleResults VariableShapeSample(System.Nullable<int> shape )
    {

        IExecuteResult result = this.ExecuteMethodCall(this
                                                       , ((MethodInfo) (MethodInfo.GetCurrentMethod()))
                                                       , shape);

        return (IMultipleResults) result.ReturnValue;
    }
}

4

1 に答える 1

0

DataContext.ExecuteMethodCallメソッドは内部メソッドです。あなたはそれを呼び出すことはできません。System.Data.Linq アセンブリ内のファイル内でのみアクセスできます。本当に必要な場合は、リフレクションを使用して呼び出すことができます。

Type type = typeof(NorthwindDataContext);
var methodInfo = type.GetMethod("ExecuteMethodCall", 
                                 BindingFlags.NonPublic | BindingFlags.Instance);
var currentMethod = ((MethodInfo) (MethodInfo.GetCurrentMethod()));
var result = (IExecuteResult)methodInfo.Invoke(this, 
                                 new object[] { this, currentMethod, shape });
于 2013-01-11T21:52:50.420 に答える