简体   繁体   English

从字符串构建LINQ查询

[英]Build LINQ query from a string

I have string 我有绳子

var query = new StringBuilder();
query.Append("myDb.Holiday.FirstOrDefault()");

Can I generate the linq query from this? 我可以从中生成linq查询吗?

Yes if you want to do it you have to write a parser yourself. 是的,如果要这样做,则必须自己编写一个解析器。

This awnser solves the linq OrderBy from string and from there you should be able to implement the rest of the functions you require. 遮篷从字符串中解决了linq OrderBy,从那里您应该能够实现所需的其余功能。

This is a good implementation of that awnser. 是该遮篷的良好实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM