nhibernateprimitivedetachedcriteriarestrictions

Can you create a Restriction for a Detached Criteria on a primitive collection?


I would like to know if there is a way to create a Restriction on a primitive collection of a Model in NHibernate.3.3.3?

Here's the details:

class Parent { 
    IEnumerable<string> ChildNames { get; set; }

}

I need to search like so:

private DetachedCriteria BuildQuery() {
    var inNames = { "Bob", "Sam", "Dan" };
    var query = DetachedCriteria.For<Parent>("parent");
    query.Add(Restrictions.In("ChildNames", inNames));
    return query;
}

I found this old question that says it's not possible, but given the fact that it's old and doesn't have a ton of upvotes, I'd like to confirm before I refactor.

If I can do it and I'm totally botching it, I'll take that help as well!


Solution

  • I ended up, like many, refactoring the collection into a strong type.