2011-04-29 61 views
2

我有這樣的代碼返回所有的色彩搭配有一定的文字:如何使用NHibernate的QueryOver選擇定製導致

public IEnumerable<Color> FindStartingWith(string term) 
{   
    return Session.QueryOver<Color>().Where(color => color.Name.IsLike(text, MatchMode.Anywhere)).List();   
} 

但我想要做的,是返回只包含一種顏色的列表的字符串的IEnumerable .Name ...

如何使用QueryOver做到這一點?

感謝

JUNIO

回答

7

語法可能不完全正確的,但應該是somethign像:

public IEnumerable<string> FindStartingWith(string term) 
{   
    return Session.QueryOver<Color>() 
        .Select(color => color.Name) 
        .Where(color => color.Name.IsLike(text, MatchMode.Anywhere)) 
        .List<string>();   
} 
+0

感謝您的幫助 – Junior 2011-04-29 17:57:56