Click here to Skip to main content
15,909,091 members

Comments by Ariel Quiroz (Top 5 by date)

Ariel Quiroz 16-Jan-19 7:51am View    
Obviously, I put a lot of breakpoints.
A example could be the following.
My code is this:
1 var res =_context.SomeEntity
2                  .Where(predicate)
3                  .OrderByDescending(t => t.DateCreate)
4                  .Skip(skipValue)
5                  .Take(takeValue)
6                  .ToList();
7
8     return res;


Fist time:
Input:
Data: A, B, C, D, E, F, G, H, I, J.
skipValue = 0
takeValue = 2
Output:
res = A, B

Second time:
Data: A, B, C, D, E, F, G, H, I, J.
skipValue = 3
takeValue = 2
Output:
res = A, B

Third time:
Data: A, B, C, D, E, F, G, H, I, J.
skipValue = 5
takeValue = 2
Output:
res = A, B

I hope you can understand me.
Thank you for your help.
Ariel Quiroz 15-Jan-19 14:29pm View    
Are they the same values on every pass through the method? No, they are changing. I am implementation a webApi then from my endpoint I call this method.
The data is not changing but Yes the variables skipValue and takeValue.
I am new in EntityFramework and netCore, but I think the error is in my Context or my DbSet. Because this way it is working.
var res =_context.SomeEntity.Where(predicate)
                            .OrderByDescending(t => t.DateCreate)            
                            .ToList();   
return res.Skip(skipValue).Take(takeValue).ToList();
Ariel Quiroz 15-Jan-19 10:33am View    
Yes, I used debugger even I have printed these variables and always are changing.
Ariel Quiroz 12-Jan-19 20:41pm View    
public List<someentity> Paginate(int skipValue, int takeValue, Expression<Func<SomeEntity, bool>> predicate)
{
_context.SomeEntity
.Where(predicate)
.OrderByDescending(t => t.DateCreate)
.Skip(skipValue)
.Take(takeValue)
.ToList();
}
Ariel Quiroz 12-Jan-19 20:40pm View    
Sorry, I have written bad. The name of variables are the same.