如何使用Kendo.DynamicLinqCore访问非常大的数据集

时间:2019-05-10 21:05:30

标签: .net asp.net-core kendo-grid

它一次获取所有数据,我每次都必须杀死该页面。任何帮助表示赞赏。以下是我的代码,没有take,skip参数。

 public class StudentController : Controller
     {
        private read-only IStudentService _studentService;


        public StudentController(IStudentService studentService)
        {
            _studentService = studentService;
        }


        public IActionResult Index()
        {
            return View();
        }



public IActionResult Read([DataSourceRequest] DataSourceRequest request)
 {
      //How to use the DynamiclinqCore here 
       // GetAll retuns billions of records

      return Json(_studentService.GetAll().ToDataSourceResult(request));

  }     


 }

查看:

以下是我的观点。任何帮助表示赞赏。它一次获取所有数据,每次都必须杀死该页面。任何帮助表示赞赏。以下是我的代码,没有take,skip参数。


<script>

    $(function() {
        $("#grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Url.Action("Read", "Student")",
                        dataType: 'json',
                        contentType: "application/json",
                        type: "POST"
                    },
                    parameterMap: function (data, options) {
                        debugger;
                        return JSON.stringify(options);
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    model: {
                        id: "StudentID",
                        fields: {
                            StudentID: { editable: false, nullable: true },
                            StudentName: { editable: false },
                            ParentID: { editable: false }
                        }
                    }
                },
                pageSize: 1000,
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            filterable: true,
            sortable: true,
            pageable: true,
            height: 500,
            columns: [
                { field: "StudentID", width: "150px" },
                { field: "StudentName", width: "250px" },
                { field: "ParentID", width: "250px" }
            ]
        });

    });

</script>
<div id="grid"></div>

这是我的服务

 public class StudentService : IStudentService
    {
        private readonly CBDBDataContext _context;

        public StudentService(CBDBDataContext context)
        {
            _context = context;
        }

        public IEnumerable<Student> GetAll()
        {
            return _context.Students.ToList();
        }
    }

0 个答案:

没有答案