Hi,
I'm atempting to create a custom FNH role provider in C# for an MVC3
application. I've added NHibernate and NHibernate.Criterion to my using
statemens. However, I receive a build error stating Criterion does not exist
in the current namespace. Here's the try catch block I've written:
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;
}
How should I remedy this?
Thanks,
Sid
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/h_XlkWKCb7MJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.