You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support per-operation collation using EF.Functions.Collate() or equivalent #8813
Reacted by Gabriel Smoljar, Mike Woodward, tom clements, Sam Stuewe, Carl Reinke, Paul Smith, ouvré thomas, Collin Barrett, Adam Jež, Benjamin Todts and 7 more
I prefer somesthing like Like(string matchExpression, string pattern,string escapeCharacter, Collation collate), where Collation is an enum of valid collate names for COLLATE.
It would be great if it works for all string queries, but how?
A possible design is an extension method AsCollation(this string dbString, Collation collate), but the type string is too common, I don't think it is a good idea to add a extension method for such a type. Or the method should be a common static method (just remove the this).
By the way, there should be an approach to specify the collation when creating a table or adding a column.
Reacted by Paul Smith, wpfdev, Juanjo Albiach and lixaotec
Yes, it should not be an extension method on string. We could have an enum if we can figure out a nice way to encode all possibilities that is somewhat future-proof.
Activity
divega commentedon Jun 12, 2017
@OpportunityLiu can you explain how what you propose would behave and what makes LIKE a good place to add the ability to specify collations?
It seems to me it would be useful to be able to specify collations for all string values passed to the database in queries, not just for LIKE.
OpportunityLiu commentedon Jun 13, 2017
I prefer somesthing like
Like(string matchExpression, string pattern,string escapeCharacter, Collation collate), whereCollationis an enum of valid collate names for COLLATE.It would be great if it works for all string queries, but how?
A possible design is an extension method
AsCollation(this string dbString, Collation collate), but the typestringis too common, I don't think it is a good idea to add a extension method for such a type. Or the method should be a common static method (just remove thethis).By the way, there should be an approach to specify the collation when creating a table or adding a column.
divega commentedon Jun 13, 2017
@OpportunityLiu The basic SQL Server example could look like this:
Yes, it should not be an extension method on string. We could have an enum if we can figure out a nice way to encode all possibilities that is somewhat future-proof.
divega commentedon Jun 14, 2017
For columns it is apparently already possible to append the collation to the store type. For database we should have a separate feature.
[-]Support COLLATE in EF.Functions.Like()[/-][+]Support EF.Functions.Collate()[/+]22 remaining items
New EF.Functions.Collate
New EF.Functions.Collate
roji commentedon Apr 20, 2020
Added doc note on EF.Functions.Collate about index/perf impact. I think there's nothing more pending here @smitpatel.
New EF.Functions.Collate
New EF.Functions.Collate (#20603)
lixaotec commentedon Aug 28, 2020
Dont know if its already planned, but would be nice to have a
WHERE name LIKE '%joão%' COLLATE Latin1_General_CS_AS (EF.Functions.Like)
roji commentedon Aug 29, 2020
Yeah, this is supported, you can try out the latest preview or dailies:
Note that the collate is applied to the column instead of to the constant - because of #22317 - but the result is the same.