roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

RCS1155 in LINQ to SQL

Open nvmkpk opened this issue 7 years ago • 6 comments
trafficstars

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).

nvmkpk avatar Sep 10 '18 15:09 nvmkpk

Could you provide an example?

josefpihrt avatar Sep 10 '18 15:09 josefpihrt

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.

nvmkpk avatar Sep 10 '18 18:09 nvmkpk

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.

LesRamer avatar Sep 14 '18 16:09 LesRamer

Not in case of Oracle. Oracle does case sensitive comparisons.

nvmkpk avatar Sep 16 '18 14:09 nvmkpk

RCS1202 also does not apply to LINQ to SQL.

nvmkpk avatar Sep 25 '18 00:09 nvmkpk

Applying this refactoring can cause exceptions when working with IQueryable and EntityFrameworkCore

sevenam avatar Jul 07 '21 11:07 sevenam