Execute stored procedure using entity framework

前端 未结 4 775
鱼传尺愫
鱼传尺愫 2020-12-29 15:43

is it possible to execute a stored procedure using EF, that select records from database from two or more tables using inner join and left outer join.

my point of vi

4条回答
  •  灰色年华
    2020-12-29 16:38

    you can use ExecuteFunction of ObjectContext class:

     public virtual ObjectResult NameOfStoredProcedure(Nullable tableID)
        {
            var IDParameter = tableID.HasValue ?
                new ObjectParameter("tableID", tableID) :
                new ObjectParameter("tableID", typeof(int));
    
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("NameOfStoredProcedureInSQLDatabase", IDParameter);
        }
    

提交回复
热议问题