I'm pretty sure the TOP(?) parameter is not being passed in.

On Apr 13, 10:31 am, Jim Wheaton <[email protected]> wrote:
> I've recently upgraded to NH 3.0.0.4000 and updated RhinoSecurity to
> work against this version.  I notice that when:
>
> 1) I call AddPermisionsToQuery on a DetachedCriteria that is used in a
> subquery
> 2) and I'm running against SQL Server 2008 (SQLite works fine)
>
>  I get the following exception:
>
> System.Collections.Generic.KeyNotFoundException : The given key was
> not present in the dictionary.
>
> Looking at the sql that is generated, it appears that NH is missing
> one of the parameters.  I think it is not passing a param for the
> first (WHERE ?) or second (SELECT TOP(?)) args:
>
> SELECT <my columns>
>  FROM MyTable this_
> WHERE this_.Id in (SELECT distinct this_0_.Id as y0_
>                              FROM MyTable this_0_ WHERE ? = (SELECT
> TOP (?) this_0_0_.Allow as y0_ FROM security_Permissions this_0_0_
> inner join security_Operations op1_ on
> this_0_0_.Operation=op1_.Id left outer join security_EntitiesGroups
> entitygrou2_ on this_0_0_.EntitiesGroup=entitygrou2_.Id left outer
> join security_EntityReferencesToEntitiesGroups entities7_ on
> entitygrou2_.Id=entities7_.GroupId left outer join
> security_EntityReferences entitykey3_ on
> entities7_.EntityReferenceId=entitykey3_.Id WHERE op1_.Name in
> (?, ?, ?) and (this_0_0_.[User] = ? or this_0_0_.UsersGroup in (SELECT
> this_0_0_0_.Id as y0_ FROM security_UsersGroups this_0_0_0_ WHERE
> this_0_0_0_.Id in (SELECT this_0_0_0x0_.Id as y0_ FROM
> security_UsersGroups this_0_0_0x0_ left outer join
> security_UsersToUsersGroups users4_ on
> this_0_0_0x0_.Id=users4_.GroupId left outer join Users user1_ on
> users4_.UserId=user1_.UserId left outer join
> security_UsersGroupsHierarchy allchildre6_ on
> this_0_0_0x0_.Id=allchildre6_.ParentGroup left outer join
> security_UsersGroups child2_ on allchildre6_.ChildGroup=child2_.Id
> WHERE (child2_.Id in (SELECT this_0_0_0x0_.Id as y0_ FROM
> security_UsersGroups this_0_0_0x0_ inner join
> security_UsersToUsersGroups users3_ on
> this_0_0_0x0_.Id=users3_.GroupId inner join Users user1_ on
> users3_.UserId=user1_.UserId WHERE user1_.UserId = ?) or user1_.UserId
> = ?)))) and ((this_0_.SecurityKey = this_0_0_.EntitySecurityKey or
> this_0_.SecurityKey = entitykey3_.EntitySecurityKey) or
> (this_0_0_.EntitySecurityKey is null and this_0_0_.EntitiesGroup is
> null)) ORDER BY this_0_0_.Level desc, this_0_0_.Allow asc)) ]
>
> Positional parameters:  #0>True #1>/data/myentity/select #2>/data/
> myentity #3>/data #4>Core.User #5>1 #6>1
>
> My criteria looks like this.  I'm just doing a self join on the table
> because it only throws this exception on detachedcriteria subqueries
>
> var detached = DetachedCriteria.For<T>()
>                .SetProjection(Projections.Distinct(Projections.Id()));
>
> AuthorizationService.AddPermissionsToQuery(CurrentUserService.User,
> SelectOperation, detached);
>
>             var criteria = Session.CreateCriteria<T>("parent")
>                     .Add(Subqueries.PropertyIn("Id", detached));
>
>             criteria.List<T>();
>
> Any ideas?  Why would this work against SQLite but not SQL Server?

-- 
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.

Reply via email to