这是我的数据集:
1 David
2 David
3 Marc
4 Marc
5 Marc
6 Marc
7 Marc
8 Marc
9 Marc
10 Marc
11 Marc
12 Marc
13 Marc
14 Marc
15 Marc
此查询返回2条记录(正确):
query = query.Where(Log => SqlMethods.Like
(Log.FormattedMessage, "%<key>Name</key><value>David</value>%"));
此查询返回2条记录(正确):
query = query.Where(Log => SqlMethods.Like
(Log.FormattedMessage, "%<key>Name</key><value>%David%</value>%"));
此查询返回0条记录(正确):
query = query.Where(Log => SqlMethods.Like
(Log.FormattedMessage, "%<key>Name</key><value>av</value>%"));
此查询返回2条记录(正确):
query = query.Where(Log => SqlMethods.Like
(Log.FormattedMessage, "%<key>Name</key><value>%av%</value>%"));
此查询返回0条记录(正确):
query = query.Where(Log => SqlMethods.Like
(Log.FormattedMessage, "%<key>Name</key><value>v</value>%"));
此查询返回15条记录(不正确,应返回2):
query = query.Where(Log => SqlMethods.Like
(Log.FormattedMessage, "%<key>Name</key><value>%v%</value>%"));
上次查询有什么问题?这是一个错误还是我错过了什么?
答案 0 :(得分:2)
"%<key>Name</key><value>%v%</value>%"
键/值之前/之后是什么?例如,我可以想象这匹配它:
&lt; key&gt;名称&lt; / key&gt;&lt; value&gt; Stan&lt; / value&gt;&lt; v alue&gt; Kyle &lt; / value&gt;
答案 1 :(得分:0)
我能看到的唯一原因是,你有%v%
作为过滤器,这意味着在正则表达式(。+)v(。+)中,基本上是任何带有v的值。如果这不是解决方案,您可以发布查询结果吗?