i have the following code
Regex R = new Regex("my regex");
var q = from c in db.tble1
where R.IsMatch(c.text)
select c;
and while debugging i saw in the q result this message
Method ‘Boolean IsMatch(System.String)’ has no supported translation to SQL.”} System.SystemException {System.NotSupportedException}
so what have i done wrong ?
Edit:I learned that the method has no supported translation to SQL
but how to solve this
Regex has no supported translation to SQL. The error says it all. You can’t use regex in LINQ to SQL.
Try using a
likeorsubstringcomparison instead:Or, you could perform an in memory regex comparison. You can do this by calling
ToList()before using theRegex: