I've always said one of the best non-major-related courses I took in college was Criminal Justice 101, which went through all the most applicable SCOTUS case law for common scenarios. Ignoring the variation in state laws, you could boil it down to about 30 rules of thumb. Many of the most important are covered in the classic YouTube lecture 'Don't talk to the police.'
Teaching this as a requires HS class would be an incredible benefit to society, because, on the flip side, many police encounters escalate to violence because the citizen has an incorrect understanding of where their rights end/don't exist.
The most obvious rule to follow is that you should always assert your rights (correct or incorrect) verbally only, as soon as you involve physical resistance, the situation will deteriorate rapidly (for you.) Any violations of your rights will be argued and dealt with in court, not on the street. Confirm requests/demands from officers are 'lawful orders', and then do them.
It worked for years for the SomethingAwful forums. A nominal charge for the ability to post, with plenty of 'timeout' chances for rehabilitation before an outright ban keeps out most of the junk.
It feels wrong at first to pay for commenting on a forum, but the alternative is almost always a gentle slide towards a trash dump. AI means that slide is almost a vertical slope.
I've found and fixed this bug before. There are 2 other ways to handle it
Dapper has a static configuration for things like TypeMappers, and you can change the default mapping for string to use varchar with: Dapper.SqlMapper.AddTypeMap(typeof(string),System.Data.DbType.AnsiString). I typically set that in the app startup, because I avoid NVARCHAR almost entirely (to save the extra byte per character, since I rarely need anything outside of ANSI.)
Or, one could use stored procedures. Assuming you take in a parameter that is the correct type for your indexed predicate, the conversion happens once when the SPROC is called, not done by the optimizer in the query.
I still have mixed feelings about overuse of SQL stored procedures, but this is a classic example of where on of their benefits is revealed: they are a defined interface for the database, where DB-specific types can be handled instead of polluting your code with specifics about your DB.
(This is also a problem for other type mismatches like DateTime/Date, numeric types, etc.)