I am working on converting some existing Linq to SQL into Compiled Queries, partially using this useful article as a guide.
The following is an example of one of my original statements:
private IQueryable<Widget> GetWidgetQuery()
{
return db.Widgets.Where(u => (!u.SomeField.HasValue || !u.SomeField.Value));
}
Here is my attempt to create a compiled request:
private static readonly Func<DBDataContext, IQueryable<Widget>> GetWidgetQuery =
CompiledQuery.Compile((DBDataContext db) =>
db.Widgets.Where(u => (!u.SomeField.HasValue || !u.SomeField.Value)));
I am having trouble visualizing the differences between the standard and compiled implementations of this query. Assuming my syntax is correct, will the compiled query return the same data as the standard, only with the benefits used in Compiled queries?
source
share