Hi! I have a simple question regarding performance as I've seen this situtation happen before and just wanted to make sure. When we use GetAll, from IRepository, and then filter results... is the whole table fetched from the table and then filtered or is it filtered before fetching to database? Thanks in advance.
3 Answer(s)
-
0
I had a look at the sql generated using SQL Profiler and in both the following cases the WHERE clause was added limiting the rows fetched from the table.
_myRepository .GetAll() .Where(e => e.AssetId == input.AssetId && e.StartTime >= input.StartTime) .WhereIf(input.EndTime.HasValue, e => e.EndTime <= input.EndTime)
_myRepository .GetAllList((a => a.Core.IsActive == true && a.Core.ApplicationId == input.ApplicationId));
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Thanks Terry. My SQL profiler has been giving me trouble and I couldn't find any way to see how it was working underneath. Thanks a lot!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi there, since GetAll() returns a Queryable, this indicates it filters on database. Since the SQL Query is not called yet and still in production. It will first be evaluated, when you call .ToList() or iterate manually over it. On the other hand: Thanks for evaluating this again :)
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)