Ignoring accents while searching the database using Entity Framework

后端 未结 4 1672
长发绾君心
长发绾君心 2020-12-11 15:23

I have a database table that contains names with accented characters. Like ä and so on.

I need to get all records using EF4 from a table that contains s

4条回答
  •  心在旅途
    2020-12-11 15:45

    Setting an accent-insensitive collation will fix the problem.

    You can change the collation for a column in SQL Server and Azure database with the next query.

    ALTER TABLE TableName
    ALTER COLUMN ColumnName NVARCHAR (100)
    COLLATE SQL_LATIN1_GENERAL_CP1_CI_AI NOT NULL
    

    SQL_LATIN1_GENERAL_CP1_CI_AI is the collation where LATIN1_GENERAL is English (United States), CP1 is code page 1252, CI is case-insensitive, and AI is accent-insensitive.

提交回复
热议问题