I have two objects, when I call member functions to retrieve data from the database, order or calling these functions effecting the results.
Whichever function I call the second time, it is returning extra data:
IQueryable<SameClass> object_1;
IList<SameClass> object_2;
I'm calling functions like this:
object_1= this.sameService.function1();
object_2= this.sameService.function2();
And finally in these functions, I'm calling same repository for data access:
IQueryable<SameClass> object_3= this.sameRepo.GetMany(whr => data checks).AsNoTracking();
IList<SameClass> object_3 = this.sameRepo.GetAll().ToList();
For example, if I call object_2 = this.sameService.function2()
after object_1= this.sameService.function1()
, it returns 51 records, but when I call it first, it returns 34 records which is the correct response.
I've tried adding an IDisposable
to SameClass
and when I create IQueryable<SameClass>
, used it with try{} finally{}
blocks where I dispose the object, and added .AsNoTracking()
but results are still the same.
What am I missing?