Hi,
I ran into a problem where the following code snipped produced a SQL
error that complains about a duplicate identifier in table
security_EntityTypes:
foreach (var objAddress in objAddresses)
{
AuthorizationRepository.AssociateEntityWith(objAddress,
objEntityGroup);
}
UnitOfWork.Current.TransactionalFlush();
The problem was that "AssociateEntityWith" query an EntityType
instance for the given entity which wasn't created/saved yet. I'm
using NHRepository as IRepository implementation.
I'm currently using the following piece of code to reliably create the
given EntityType instance:
var objEntityTypes =
UnitOfWork.CurrentSession.CreateCriteria(typeof
(Rhino.Security.Model.EntityType))
.Add(NHibernate.Criterion.Expression.Eq("Name", typeof
(Address).FullName))
.List<Rhino.Security.Model.EntityType>();
if (objEntityTypes.Count == 0)
{
var objEntityType = new Rhino.Security.Model.EntityType
() { Name = typeof(Address).FullName };
UnitOfWork.CurrentSession.Save(objEntityType);
UnitOfWork.Current.TransactionalFlush();
}
... or is there a better way? The problem is that I have to call this
snippet for every entity to every ASP.NET page that does something
security related which seems to be an overhead I want to avoid.
Regards,
Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
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/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---