Is there any way to force LINQ to SQL to perform a case-insensitive Contains?
I'm working with PostgreSQL on Entity Framework Core.
Is there any way to force LINQ to SQL to perform a case-insensitive Contains?
I'm working with PostgreSQL on Entity Framework Core.
Case insensitive name of tables and properties in Entity Framework 7
With reference to the answer above, no. There is no way to further load case sensitivity checks at an even lower level. You'll have to perform exactly what this person did:
How do I make contains case-insensitive in ef core 2?
Here's an example on the latest LINQ syntax.
var tickerObj = _unitOfWork.GetRepository<CurrencyPair>()
.GetQueryable()
// .Where() and .Include() omitted for brevity
.SingleOrDefault(cp => string.Concat(
cp.PartialCurrencyPairs.FirstOrDefault(pcp => pcp.IsMain).Currency.Abbrv,
cp.PartialCurrencyPairs.FirstOrDefault(pcp => !pcp.IsMain).Currency.Abbrv)
.Equals(ticker, StringComparison.InvariantCultureIgnoreCase)
&& cp.CurrencySource.Abbreviation.Equals(exchangeAbbrv, StringComparison.InvariantCultureIgnoreCase));
Focus on the SingleOrDefault() segment:
cp.CurrencySource.Abbreviation.Equals(exchangeAbbrv, StringComparison.InvariantCultureIgnoreCase)