I am working on WEB API. I have created an api which gives me details. The details should be after nth interval. Below is my code.
var mainDetails = kesc.tj_xhqd.Where(m => (m.zdjh == msn) && (m.sjsj >= dt)).AsEnumerable() .Select((x, i) => new { MSN = x.zdjh, PingDateTime = x.sjsj, PingValue = x.xhqd, i = i }) .Where(x => x.i % interval == 0) .ToList(); return Request.CreateResponse(HttpStatusCode.OK, new { details = mainDetails }); The output is
{ "details": [ { "MSN": "002999001180", "PingDateTime": "2018-05-16T18:39:52", "PingValue": "19", "i": 0 }, { "MSN": "002999001180", "PingDateTime": "2018-05-16T18:39:52", "PingValue": "19", "i": 24 }, { "MSN": "002999001180", "PingDateTime": "2018-05-16T18:39:52", "PingValue": "19", "i": 48 }, { "MSN": "002999001180", "PingDateTime": "2018-05-16T18:39:52", "PingValue": "19", "i": 72 }, { "MSN": "002999001180", "PingDateTime": "2018-05-16T18:39:52", "PingValue": "19", "i": 96 }, . . . . . { "MSN": "002999001180", "PingDateTime": "2018-05-16T18:39:52", "PingValue": "19", "i": 144 }, ] } The i value is incremented but the other details are repeated again and again. In actual the ping value comes after every 2 minutes, ping value can be same but not the date time.
Update 1
Below is my snapshot of the table taken directly from DB
From the above picture, it is clearly seen that only ping value i.e. 19 is repeated several times but the date time is only single but still the date time 2018-05-16T18:39:52 is shown multiple times
Update 2
Here is my DB context that will implement my model
public partial class kescEntities : DbContext { public kescEntities() : base("name=kescEntities") { this.SetCommandTimeOut(10000); } public void SetCommandTimeOut(int Timeout) { var objectContext = (this as IObjectContextAdapter).ObjectContext; objectContext.CommandTimeout = Timeout; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); } public virtual DbSet<tj_xhqd> tj_xhqd { get; set; } } How can I set my query in a way that I can get all different records after the interval?
Any help would be highly appreciated.

nthrecord in my table.