给出以下实体 -
public class Friend
{
public virtual string Name { get; set; }
public virtual IEnumerable<string> Nicknames { get; set; }
}
映射如下:
mapping.HasMany(x => x.Nicknames).Element("Value") //this gets auto-mapped to a different 'Nicknames' table
给定一个字符串,我想要检索朋友的姓名或他的一个昵称与该字符串匹配 我无法弄明白该怎么做..这就是我到目前为止所做的:
.Where(Restrictions.Or(
Restrictions.On<Friend>(f => f.Name).IsInsensitiveLike(name),
Restrictions.On<Friend>(f => f.Nicknames) // i'd like to be able to do: .Contains(name)
)
).List();