我有一个实体及其映射:
public class Test
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
}
public class TestMap : EntityMap<Test>
{
public TestMap()
{
Id(x => x.Id);
Map(x => x.Name);
Map(x => x.Description);
}
}
我正在尝试对其运行查询(将其从数据库中获取):
var keyword = "test" // this is coming in from the user
keyword = keyword.ToLower(); // convert it to all lower-case
var results = session.Linq<Test>
.Where(x => x.Name.ToLower().Contains(keyword));
results.Count(); // execute the query
但是,每当我运行此查询时,都会出现以下异常:
Index was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index
我说的对吗,目前,Linq to NHibernate 不支持ToLower()
?如果是这样,是否有替代方法允许我在 Linq to NHibernate 兼容的另一个字符串中间搜索一个字符串?例如,如果用户搜索kap
,我需要它来匹配Kapiolani
、Makapuu
和Lapkap
。