Strange LINQ to SQL Behavior
Posted
by mcass20
on Stack Overflow
See other posts from Stack Overflow
or by mcass20
Published on 2010-06-09T13:29:54Z
Indexed on
2010/06/09
13:32 UTC
Read the original article
Hit count: 215
What is wrong with the last query? Is it a bug or am I missing something?
This query returns 2 records (correct):
query = query.Where(Log => SqlMethods.Like(Log.FormattedMessage, "%<key>Name</key><value>David</value>%"));
This query returns 2 records (correct):
query = query.Where(Log => SqlMethods.Like(Log.FormattedMessage, "%<key>Name</key><value>%David%</value>%"));
This query returns 0 records (correct):
query = query.Where(Log => SqlMethods.Like(Log.FormattedMessage, "%<key>Name</key><value>av</value>%"));
This query returns 2 records (correct):
query = query.Where(Log => SqlMethods.Like(Log.FormattedMessage, "%<key>Name</key><value>%av%</value>%"));
This query returns 0 records (correct):
query = query.Where(Log => SqlMethods.Like(Log.FormattedMessage, "%<key>Name</key><value>v</value>%"));
This query returns 15 records (incorrect, should return 2):
query = query.Where(Log => SqlMethods.Like(Log.FormattedMessage, "%<key>Name</key><value>%v%</value>%"));
© Stack Overflow or respective owner