コード例 #1
0
        public JsonResult GetDSR([DataSourceRequest] DataSourceRequest request)
        {
            using (var conn = _context.Database.GetDbConnection())
            {
                var query = request.ToSqlQuery("Blogs");
                var data  = conn.Query(query);

                var countQuery = request.ToSqlCountQuery("Blogs");
                var count      = conn.ExecuteScalar <int>(countQuery);

                DataSourceResult dsr = new DataSourceResult();
                dsr.Data  = data;
                dsr.Total = count;
                JsonResult result = Json(dsr);
                return(result);
            }
        }