I’ve searched the internet for a possibly of generating
dynamic queries
using Linq to Sql and discovered that there really isn’t
anything obvious
that may be inherently possible within the LINQ scope
itself.
I’ve seen a somewhat workable method for doing dynamic
queries
in Mike Taulty’s blog by use of reflection: http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2007/06/15/9489.aspx
Giving it some thought, the fact that Linq has the field
names integrated
as properties of the DataContext class does not lend
itself to creating dynamic
queries like in ADO / T-SQL or what have you (where you
simply generate the
query string before it is executed.)
Doing an “ExecuteCommand” or “ExecuteQuery<>” off of
the DataContext
may do the trick, but again one is resorting to using
strings for generating
dynamic queries.
A database application making use of Linq to Sql would need
custom function
calls. A function like “GetAllCustomers(…)” would be all
too common in a
Linq to Sql application, or not?
By Frank Neubecker