I have one collection where I need to queryOver and add the restriction.
public class User {
public int Id {get;set;}
public string Name {get;set;}
public IList<Role> Roles {get;set;}
}
Now I want to query over in Nhibernate and also I need to get the result if the user passess to get any role with Admin role.
Conjunction conjunction = new Conjunction();
Disjunction disjunction = new Disjunction();
if (!string.IsNullOrEmpty(search))
{
disjunction.Add(Restrictions.On<User>(e => e.Name)
.IsLike(string.Format("%{0}%", search)));
conjunction.Add(disjunction);
}
IList<User> users = NhSession.QueryOver<User>()
.Where(conjunction)
.OrderBy(x => x.Name).Asc()
.Take(maxResults)
.List();
How can I filter if I have a string parameter of RoleName and get those record from the query.