简体   繁体   English

jquery数据表如何填充ajax请求

[英]jquery data table how to populate on ajax request

Since my previous question was too confused I'm asking a new one. 由于我上一个问题太混乱,我要问一个新问题。

I'm having this linq which I use to retrive data as json 我有这个linq用于将数据作为json进行检索

var res = from c in model.Data 
          select new object[] { c.Id, c.Time, c.Number};

c.Time is DateTime object and Id and Number are integers. c.Time是DateTime对象,Id和Number是整数。 Now, when this query is executed I'm getting same data repeated in number of model.Data counts. 现在,当执行此查询时,我在模型的数量上重复了相同的数据。数据计数。 How can this query be rewriten to use foreach loop. 如何重写此查询以使用foreach循环。

you are creating an array of objects' array 你正在创建一个对象数组的数组

Please use this: 请使用这个:

var res = from c in model.Data 
          select new { ID=c.Id, Time=c.Time, Number=c.Number};

Then the variable will contain a List of objects with Properties ID, Time and Number. 然后该变量将包含具有属性ID,时间和数字的对象列表。 This List will be easy to convert to JSON array of objects. 此List将很容易转换为JSON对象数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM