c# - Get all users, only when they don't occur in another table -


i have 2 tables. 1 user table , 1 table in results placed of test.

when user takes test result , user_id placed in results table. when user never took test user_id won't in results table.

i need users not in results table. there way in 1 query? (entity framework)

getting users easy. need way link results table see of users want in result set.

(from u in entity.users [where not in results table..??] select u);  

fully working example, using mock objects:

using system; using system.collections.generic; using system.linq; using system.text;  namespace consoleapplication1 {     class program     {         static void main(string[] args)         {              var userstakentest = new list<string>() { "bob", "jim", "angel" };             var allusers = new list<string> { "bob", "jim", "angel", "mike", "jimbobhouse" };              var users = user in allusers                         join usertakentest in userstakentest on user equals usertakentest tempusers                         newusers in tempusers.defaultifempty()                         string.isnullorempty(newusers)                         select user;              foreach (var user in users)             {                 console.writeline("this user has not taken test: " + user);             }             console.readline();         }     } } 

.defaultifempty() after - if brings empty result have object in table not show in table b.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -