I have two methods in my log repository.
public IEnumerable<Log> GetAll()
{
var db = new CasLogEntities();
return db.Logs;
}
public DbSet<Log> GetAllSet()
{
var db = new CasLogEntities();
return db.Logs;
}
The only difference is that one returns an IEnumerable from the log, and the other returns the DbSet of the log.
In My Asset Controller, I have the following code
var allLogs = _logRepo.GetAllSet();
var Logs = (from log in allLogs
group log by log.DeviceId
into l
select new {DeviceId = l.Key, TimeStamp = l.Max(s => s.TimeStamp)}).ToList();
Now the problem is that I get a huge difference in performance in the application group, depending on which of the repo methods I call.
- getAllSet, which returns a DbSet, lightning fast,
- GetAll returns IEnumerable more slowly.
- . , DbSet IEnumerable GetAll Query, . GetAllSet "ToList()" , , , .
? ?
, GetAll IEnumerable, , .