QueryOver-添加对原始集合的限制 [英] QueryOver - add restriction on primitive collection

查看:80
本文介绍了QueryOver-添加对原始集合的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下实体-

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

给定一个字符串,我想检索名字或他的昵称之一与该字符串匹配的朋友.
我不知道该怎么做..这是到目前为止我得到的:

given a string, I want to retrieve friend who's name or one of his nicknames matches that string.
I can't figure out how to do that.. here's what I've got so far:

.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();

推荐答案

证明这是nHib中的一个已知问题(实际上,也是Hibernate中的问题).
参见此处.
我最终为此使用了查询API.

turns out that this is a known issue in nHib (and in fact, in Hibernate as well).
see here.
I ended up using the Query API for this one.

这篇关于QueryOver-添加对原始集合的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆