none
DataContext.ExecuteMethodCall

    Question

  • Official documentation says that "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code." - http://msdn.microsoft.com/en-us/library/bb493883(v=vs.110).aspx

    But as far as I'm aware - it's a primary way to call the stored procedure from LinqToSql. What's behind this "not intended" note?

    • Edited by Eugene Kiba Tuesday, November 05, 2013 2:01 PM
    Tuesday, November 05, 2013 2:00 PM

Answers

  • Hello,

    >>But as far as I'm aware - it's a primary way to call the stored procedure from LinqToSql.

    Yes, it is the primary way for us to call the stored procedure from LinqToSql.

    >>What's behind this "not intended" note?

    It means that we cannot call the method in business layer directly like below:

    using (DataClasses1DataContext dataContext = new DataClasses1DataContext())
    
                {
    
                    IExecuteResult result = dataContext.ExecuteMethodCall(dataContext, ((MethodInfo)(MethodInfo.GetCurrentMethod())), 1);
    
                }
    

    Because this method is protected.

    We call it through a layer of packaging in DataContext class like below:

    using (DataClasses1DataContext dataContext = new DataClasses1DataContext())
    
                {
    
                    var restult = dataContext.ProTest1(1);
    
                }

    In the DataContext Class, when we import a store procedure form database to LINQ to Sql, it will create the method like below and then it will call the ExecuteMethodCall() method.

    So we just need to call the created method.

    [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.ProTest1")]
    
                  public ISingleResult<ProTest1Result> ProTest1([global::System.Data.Linq.Mapping.ParameterAttribute(Name="OrderID", DbType="Int")] System.Nullable<int> orderID)
    
                  {
    
                         IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), orderID);
    
                         return ((ISingleResult<ProTest1Result>)(result.ReturnValue));
    
                  }
    

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Eugene Kiba Thursday, November 07, 2013 9:27 AM
    Wednesday, November 06, 2013 1:48 AM