I’m using Fluent NHibernate in an ASP.NET MVC3 project. I’m coding up a custom membership provider and have setup a FNHRoleProvider class. Part of it contains the following try catch blocK:
private Entities.Roles GetRole(string rolename)
{
Entities.Roles role = null;
using (ISession session = SessionFactory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
try
{
role = session.CreateCriteria(typeof(Entities.Roles))
.Add(NHibernate.Criterion.Restrictions.Eq("RoleName", rolename))
.Add(NHibernate.Criterion.Restrictions.Eq("ApplicationName", this.ApplicationName))
.UniqueResult<Entities.Roles>();
//just to lazy init the collection, otherwise get the error
//NHibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
IList<Entities.Users> us = role.UsersInRole;
}
catch (Exception e)
{
if (WriteExceptionsToEventLog)
WriteToEventLog(e, "GetRole");
else
throw e;
}
}
}
return role;
}
I’m receiving an error stating that Criterion doesn’t exists in the current namespace, despite the fact that I’ve added NHibernate.Criterion to my using statement. I’m also able to view this portion of the namespace in Object Browser.
How can I resolve the build error?
i suspect you named your namespace NHibernate as well so better remove
NHibernate.Criterion.beforeRestrictions