linq case insensitive (without toUpper or toLower)

前端 未结 8 2637
执念已碎
执念已碎 2020-12-15 02:27
public Articles GetByName(string name, Categories category, Companies company)
{
    var query = from article in session.Linq()
                where         


        
8条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 03:02

    Use string.Equals(name, article.Name, StringComparison.OrdinalIgnoreCase) when you are sure that your database supports it.

    E.g. SQLite with a collate of NOCASE will ignore the option. Oracle uses session settings NLS_COMP, NLS_SORT that will be taken.

    Else use ToLower() or ToUpper() when you have no culture issues.

提交回复
热议问题