如何在NHibernate上使用QueryOver选择自定义结果
我使用以下代码返回所有颜色,其中包含一些文本:如何在NHibernate上使用QueryOver选择自定义结果,nhibernate,Nhibernate,我使用以下代码返回所有颜色,其中包含一些文本: public IEnumerable<Color> FindStartingWith(string term) { return Session.QueryOver<Color>().Where(color => color.Name.IsLike(text, MatchMode.Anywhere)).List(); } public IEnumerable Fin
public IEnumerable<Color> FindStartingWith(string term)
{
return Session.QueryOver<Color>().Where(color => color.Name.IsLike(text, MatchMode.Anywhere)).List();
}
public IEnumerable FindStartingWith(字符串术语)
{
return Session.QueryOver().Where(color=>color.Name.IsLike(text,MatchMode.Anywhere)).List();
}
但我想做的是,返回一个字符串IEnumerable,其中只包含一个color.Name列表
我怎样才能用QueryOver做到这一点
谢谢
JUnito的语法可能不完全正确,但应该是:
public IEnumerable<string> FindStartingWith(string term)
{
return Session.QueryOver<Color>()
.Select(color => color.Name)
.Where(color => color.Name.IsLike(text, MatchMode.Anywhere))
.List<string>();
}
public IEnumerable FindStartingWith(字符串术语)
{
return Session.QueryOver()
.Select(颜色=>color.Name)
.Where(color=>color.Name.IsLike(text,MatchMode.Anywhere))
.List();
}