Esempio n. 1
0
        private IList<PermissionDTO> GetPermissions()
        {
            using (var session = Hibernate.SessionFactory.OpenSession())
            {
                Permission p = null;
                UserRole r = null;
                User u = null;

                var permissions = session.QueryOver(() => p)
                    .JoinAlias(() => p.Roles, () => r)
                    .JoinAlias(() => r.Users, () => u)
                    .Where(Res.Eq(Pro.Property("u.Id"), AuthenticatedUser.Id.Value))
                    .SelectList(l => l
                        .Select(Pro.Group(() => p.Id))
                        .Select(Pro.Group(() => p.Name)))
                    .TransformUsing(Transformers.AliasToBeanConstructor(typeof(PermissionDTO).GetConstructors()[1]))
                    .List<PermissionDTO>();

                return permissions;
            }
        }