Forcing case-insensitive strings. Entity Framework Content

Is there a way to force LINQ to SQL to be case-insensitive?

I work with PostgreSQL on the Entity Framework Core.

+5
source share
1 answer

Case-insensitive table and property names 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 will need to accomplish exactly what this person did:

How to make ef core 2 not case sensitive?

Here is an example of 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)
0
source

Source: https://habr.com/ru/post/1687791/


All Articles