I've noticed a huge difference in how NPoco (or PetaPoco) works depending on which function you call when you are using LINQ.
For instance compare Fetch() which Query() which both appear to do the same thing:
A: Fetch<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID);
B: Query<EntryImage>().Where(t => t.EntryType == type && t.EntryID == entryID);
A returns every row in the table (10,000+) and then filters client side.
B returns just the one row I'm expecting.
I find this behavior is quite dangerous - it would be very easy to write very badly performing code without really evening noticing. Is this expected behavior? If this is normal behavior, is there any way to get a list of methods which work this way, so I can avoid using them where possible?
This is expected behavior for NPoco.
As per source:
Fetch returns a list.
/// <summary>
/// Fetch all objects of type T from the database using the conventions or configuration on the type T.
/// Caution: This will retrieve ALL objects in the table
/// </summary>
List<T> Fetch<T>();
Query returns IQueryProviderWithIncludes (similar to IQueryable
)
/// <summary>
/// Entry point for LINQ queries
/// </summary>
IQueryProviderWithIncludes<T> Query<T>();