Return Result from Select Query in stored procedure to a List

前端 未结 8 2004
猫巷女王i
猫巷女王i 2021-01-01 10:10

I\'m writing a stored procedure that currently contains only a SELECT query. It will be expanded to do a number of other things, which is why it has to be a sto

8条回答
  •  情话喂你
    2021-01-01 10:27

    // GET: api/GetStudent
    
    public Response Get() {
        return StoredProcedure.GetStudent();
    }
    
    public static Response GetStudent() {
        using (var db = new dal()) {
            var student = db.Database.SqlQuery("GetStudent").ToList();
            return new Response {
                Sucess = true,
                Message = student.Count() + " Student found",
                Data = student
            };
        }
    }
    

提交回复
热议问题