What's the correct way to use ObjectResult with input parameters to StoredProcedure in Entity Framework? (Output mapped to Complex Type Property)

前端 未结 1 1738
臣服心动
臣服心动 2021-01-25 17:14

I have several listboxes which have a SelectedItem property I intend to use as input parameters to execute my stored procedure in Entity Framework.

I now realize my only

相关标签:
1条回答
  • 2021-01-25 17:51

    You can access it as a function call, and the order of the parameters is determined by EF:

    using (var db = new YourEntityContext())
    {
        var result = db.YourFunctionImportName(
            Convert.ToInt32(ddlWhatever1.SelectedValue),
            Convert.ToInt32(ddlWhatever2.SelectedValue));
    
        //Int32 used as an example, use whatever type your function import is expecting.
        //Do whatever with result.
    }
    
    0 讨论(0)
提交回复
热议问题