NHibernate Queryable 不允许字符串比较

NZJ*_*mes 5 c# nhibernate iqueryable

我有以下代码

var results =
                repository.GetItemsAsQuery<User>().Where(
                    user => user.EmailAddress.Equals(emailAddress, StringComparison.CurrentCultureIgnoreCase));

            return results.Any();
Run Code Online (Sandbox Code Playgroud)

Repository 只是我对 NHibernate 会话的包装,该方法具有以下签名

public IQueryable<T> GetItemsAsQuery<T>()
        {
            try
            {
                CheckHasErrored();

                return _connection.Session.Query<T>();
            }
            catch (Exception ex)
            {
                HasErrored = true;
                throw new DataRepositoryException(string.Format("Error getting collection of items of type '{0}'", typeof(T).Name), "DataRepository.GetItems<>", ex);        
            }
        }
Run Code Online (Sandbox Code Playgroud)

当我运行第一个方法时,我收到错误 NotSupportException - Boolean Equals(System.String, System.StringComparison) with source NHibernate。

这似乎暗示错误来自我试图过滤 NHibernate 查询的 LINQ lambda 表达式

user.EmailAddress.Equals(emailAddress, StringComparison.CurrentCultureIgnoreCase)
Run Code Online (Sandbox Code Playgroud)

我使用 NHibernate Queryable 是否错误?我希望它生成的等效 SQL 是

select * from User where emailAddress = @emailAddress
Run Code Online (Sandbox Code Playgroud)

所以我只得到通过数据网络返回的一行。

Key*_*ner 1

LINQ 尚未与 Nhibernate 100% 兼容。尝试使用String.Compare(string a, string b)替代。