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.

Return value: It is true that every element of the source sequence passes the test in the specified attest, or if the order is empty; Otherwise, wrong.

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

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -