0

In my project, I have a Member class with:

public virtual string FirstName;
public virtual string LastName;

I'm familiar with using Criteria and Disjunctions to search against the columns individually, but how can I set things up so that "Davie Jones" will return the people with first name Davie and last name Jones (or vice versa) ?

user321605
  • 846
  • 2
  • 7
  • 20
  • 2
    Does this answer your question? http://stackoverflow.com/questions/5338159/nhibernate-expression-like-criteria-on-two-fields – cmsjr Jun 13 '12 at 04:09

1 Answers1

0

If you are using nHibernate 3.0, you can use QueryOver:

IEnumerable<Member> matchingMembers = iSession.QueryOver<Member>()
                                              .Where(m => m.FirstName == firstName)
                                              .And(m => m.LastName == lastName)
                                              .List<Member>();
Andrew Shepherd
  • 44,254
  • 30
  • 139
  • 205
  • This wasn't quite what I needed, as I don't have the first and last names split up. I saw a comparable example though where you could use m => query.contains(m.FirstName).And(m => query.contains(m.LastName)) – user321605 Jun 13 '12 at 14:46