roslynator
roslynator copied to clipboard
RCS1155 in LINQ to SQL
Is it possible for you to detect when the statements causing this are being used in LINQ to SQL and do not flag them in those cases? Oracle Data Provider for .net does not support three parameter overload of string.Equals (at least on the version I am using).
Could you provide an example?
Something like:
IQueryable<Student> query = dbContext.Students;
if(!string.IsNullOrEmpty(name))
{
query = query.Where(x => string.Equals(x.Name.ToLower(), name.ToLower());
}
The Where call is to Queryable.Where and is a LINQ to SQL call. Not sure if SQL Server data provider supports the three parameter call.
I've seen similar issues with MS SqlServer as well. It is likely that the database is configured to ignore case anyway. I have removed a lot of unnecessary ToLower calls in database LINQ code.
Not in case of Oracle. Oracle does case sensitive comparisons.
RCS1202 also does not apply to LINQ to SQL.
Applying this refactoring can cause exceptions when working with IQueryable and EntityFrameworkCore