score:3
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)
.firstordefault()!=null)
.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!
Source: stackoverflow.com
Related Query
- C# SQL To Linq - Where Clause with multiple variables Comparison (var1+var2) !=(var1+var2)
- How to convert multiple SQL LEFT JOIN statement with where clause to LINQ
- SQL to LINQ - multiple tables left outer join with where clause referring right table
- linq to sql query with multiple where parameters
- LINQ query with a WHERE clause with multiple conditions
- Linq where clause with multiple conditions and null check
- Dynamic Where Clause over relational tables with LINQ to SQL
- Linq to SQL: Where clause comparing a Nullable<DateTime> with a SQL datetime null column
- Linq where clause with multiple conditions
- Linq with where clause in many-to-many EF Code First object
- Multiple level where clause filtering with Linq
- SQL INNER JOIN with WHERE clause to LINQ format
- C# - Linq optimize code with List and Where clause
- Multiple Defered WHERE clause expressions in LINQ to SQL
- Using Trim in multiple where clause of linq with Join clause
- LINQ query with multiple conditions in WHERE clause
- SQL to LINQ Query with date in where clause is not working
- LINQ Join With Multiple Where Clause
- LINQ - Left Outer Join with multiple parameters in Where clause
- How can I make this LINQ to SQL where clause with conditions faster?
- linq to entities query which has multiple where clause and one where clause with where in condition
- Expressing IN sql statement in Linq with computed string in where clause
- CRM 2011 LINQ query with multiple inner joins and a single WHERE clause (VB .NET)
- Linq multiple where clause with no or
- Total Sum with multiple where clause LINQ
- EF LINQ to SQL is getting whole table from DB instead of selection - where clause contains list with Any statement
- Entity Framework dynamic linq where from generic source with dynamic where clause
- Linq @ Where clause with multiple condition
- SQL TO LINQ Where In Clause with Max
- Linq where clause with DbFunctions.DiffDays and string comparison not working
More Query from same tag
- How to loop through a child list of objects in Entity Framework 4.1 code first
- LINQ Select Multiple value
- multiple where in linq based on parameters value
- Using .ToString inside a LINQ query select statement
- How to create Group By LINQ query
- LINQ query for XML c#
- Count string appears in list and copy along with number of time it appear into strongly type list- c#
- Func<> or method in test code?
- using linq, how can i create a IEnumerable<> from a property of another IEnumerable<>
- LINQ GroupBy Month and Color Count
- Creating a simple Linq to EF Query for a Many-To-Many relationship
- Linq group by in Entity Framework
- Implementation recommendations (tutorial) for implementing a linq interface
- Problem with checking an original database record with an edited one
- C# Random Pair generation
- isolation level in linq to sql , DataContext
- c# Sorting a Custom List
- How do I get list of object property names and values in C#?
- How to use Linq to check a list of objects property have allowed values from another list
- Using DbFunctions.TruncateDate and still have error: **The specified type member 'Date' is not supported in LINQ to Entities.**
- c# linq to sql - moving around FirstOrDefault() at end of linq breaks query
- What is LINQ and what does it do?
- 2D Array get number of not null rows
- Using subquery in entity framework
- Getting rid of outer foreach loop using linq or lambda and ensuring no duplicates are added to list
- Executing DynamicExpression with unknown types
- Using IEnumerable<T> to parse XML
- Fastest way to get values from 2d array
- Where Linq Method returning elements that don't satisfy condition
- Why does DataGrid call Linq query when scrolling?