开发者

Dynamic linq: passing entire query as string

开发者 https://www.devze.com 2023-04-08 22:50 出处:网络
Look开发者_StackOverflow社区ing at Dynamic Linq, it\'s possible to use strings to define the key parts of the query.My question is, is it possible to pass the entire query in as a string?

Look开发者_StackOverflow社区ing at Dynamic Linq, it's possible to use strings to define the key parts of the query. My question is, is it possible to pass the entire query in as a string?

ie: var foo = "from..."


LINQ stands for "Language INtegrated Queries" - it's compiled with the rest of the code, not parsed on the run. You can use Microsoft.CSharp.CSharpCodeProvider to compile your query on the run - but you will have to know in advance what local objects you want to send to the query.


That's not possible in dynamic LINQ -- dynamic LINQ only replaces specific pieces of the query. You can use ExecuteQuery on the data context in LINQ to SQL or SqlQuery on a DbSet<T>, though, to execute specific SQL commands.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号