Skip to content

Support per-operation collation using EF.Functions.Collate() or equivalent  #8813

Description

@OpportunityLiu
No description provided.

Activity

  1. added this to the Backlog milestone on Jun 12, 2017
  2. added
    help wanted
    on Jun 12, 2017
  3. added and removed
    help wanted
    on Jun 12, 2017
  4. divega commented on Jun 12, 2017

    @divega
    Contributor

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

  5. OpportunityLiu commented on Jun 13, 2017

    @OpportunityLiu
    Author

    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.

  6. divega commented on Jun 13, 2017

    @divega
    Contributor

    @OpportunityLiu The basic SQL Server example could look like this:

    var q = 
        from loc in context.Locations
        orderby EF.Functions.Collate(loc.Place, "Traditional_Spanish_CI_AI")
        select loc.Place;

    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.

  7. removed this from the Backlog milestone on Jun 13, 2017
  8. divega commented on Jun 14, 2017

    @divega
    Contributor

    By the way, there should be an approach to specify the collation when creating a table or adding a column.

    For columns it is apparently already possible to append the collation to the store type. For database we should have a separate feature.

  9. changed the title [-]Support COLLATE in EF.Functions.Like()[/-] [+]Support EF.Functions.Collate()[/+] on Jun 16, 2017
  10. 22 remaining items

  11. added 2 commits that reference this issue on Apr 11, 2020
    ea7adcf
    3943da4
  12. roji commented on Apr 20, 2020

    @roji
    Member

    Added doc note on EF.Functions.Collate about index/perf impact. I think there's nothing more pending here @smitpatel.

  13. added a commit that references this issue on Apr 23, 2020
    61947ce
  14. added a commit that references this issue on Apr 23, 2020
    d1dee85
  15. modified the milestones: 5.0.0, on May 11, 2020
  16. lixaotec commented on Aug 28, 2020

    @lixaotec

    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)

  17. roji commented on Aug 29, 2020

    @roji
    Member

    Yeah, this is supported, you can try out the latest preview or dailies:

    _ = ctx.Blogs
        .Where(b => EF.Functions.Like(EF.Functions.Collate(b.Name, "Latin1_General_CS_AS"), "%joão%"))
        .ToList();

    Note that the collate is applied to the column instead of to the constant - because of #22317 - but the result is the same.

  18. modified the milestones: , 5.0.0 on Nov 7, 2020
  19. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions