i'm not entirely certain that this is what you're looking for, but i'm going to give it a shot:

try chaining your where clauses in linq to sql, and you may get a better result:

list<string> outputroleuserlist = 
           from rls in roleuserlist
           from mis in missingroleuserlist
           where rls.roleid != mis.roleid
           where rls.userid != mis.userid
           select rls.userid + ",\"" + rls.roleid

this will actually generate sql as follows:

rls.roleid != mis.userid and rls.userid != mis.userid

however, you have already forced execution on roleuserlist and missingroleuserlist, so what you're using in the third linq statement is not really linq to sql but rather linq to objects, if i'm reading this correctly.

i'd be curious to see some additional information or clarification and then maybe i'll understand better what's going on!

edit: i realized another possibility, it's possible that the object.userid or object.roleid is throwing an internal nullpointerexception and failing out because one of those values came back null. you could possibly solve this with the following:

list<string> outputroleuserlist2=roleuserlist
    .where(x => x != null && x.userid != null && x.roleid != null && missingroleuserlist
        .where(y => y != null && y.userid != null && y.roleid != null && y.roleid!=x.roleid && y.userid!=x.userid)
    .select(x => x.userid + ",\"" + x.roleid).distinct().tolist();

this is not pretty, and this is the other linq syntax (with which i am more comfortable) but hopefully you understand what i am going for here. i'd be curious to know what would happen if you dropped this into your program (if i've guessed all of your meanings correctly!). i'll look back in a bit to see if you have added any information!

Related Query

More Query from same tag