c# - How to check with linq to sql that all users of a group have a user role? -
I want to write a DAO method which checks that all users of the group have a specific user role and either Is wrong or true.
I use the NHibernate ad LINQ.
This is what I've done so far:
Public Bull AllByGroupHaveUserRole (Group Group, UserRole userRole) {If (group == null) {New argument NullException ("group"); } If (userRole == tap) {New argument NullException ("userRole"); } Var groups = HibernateTemplate.Execute (session => (Select from user in user session by user.group == @ group group user user.UserRole.Id new user in new groupedUsers.Key} ) ).to list(); Return group Account & lt; 2 & amp; Amp; Groups All (O = & gt; OkeE == UserRoll.ID); }
Right now, I am executing the query in DB and later I check UserRole in memory.
Is this the same NHibernate query and just return results?
If there is no user in the group with a specific user role then the method should also be correct.
It is also how the LINQ method works all the method IEnumerable.
I did not test the code
session Of user in Youtube and youtube; User & gt; () Where user.Group == @ Group Group users select the users grouped by the user grouped in the new {RoleId = user.UserRole.Id}. Select (T => TUsRol.ID). Specific (). Calculate () & lt; 2 || Grouped user Where (t => T. Euserol == UserRoll). Anyone ()
Comments
Post a Comment