score:2
Accepted answer
var result = list.where(
i => !i.username.startswith("e-")
&& i.ssn != null && i.ssn != ""
&& i.displayname != null && i.displayname != ""
&& i.lastname != null && i.lastname != ""
&& i.firstname != null && i.firstname != ""
&& (condition?
i.whenchanged.hasvalue && i.whenchanged.value > datetime.utcnow.add(_whenchangedtimespan)
: true)).tolist();
score:0
var firstqueryresult = yourinput.where(i =>
!i.username.startswith("e-") &&
i.ssn != null && i.ssn != "" &&
i.displayname != null && i.displayname != "" &&
i.lastname != null && i.lastname != "" &&
i.firstname != null && i.firstname != "" &&
).tolist();
var secondqueryresult = firstqueryresult
.where(i=> i.whenchanged.hasvalue && i.whenchanged.value > datetime.utcnow.add(_whenchangedtimespan))
.tolist();
score:0
var result = (...).where(
i => !i.username.startswith("e-")
&& i.ssn != null && i.ssn != ""
&& i.displayname != null && i.displayname != ""
&& i.lastname != null && i.lastname != ""
&& i.firstname != null && i.firstname != ""
).tolist();
var filteredresult = result.where(i.whenchanged.hasvalue && i.whenchanged.value > datetime.utcnow.add(_whenchangedtimespan)).tolist();
Source: stackoverflow.com
Related Query
- Combine linq queries together
- How do I combine these two linq queries into a single query?
- How do I combine multiple linq queries into one results set?
- Combine two LINQ queries from different sources into single object
- Is there a way to combine two LINQ queries into one?
- LINQ Combine Queries
- using let keyword in linq to combine queries
- Combine 2 LINQ queries
- combine 2 queries from the same table into one linq query
- Combine two LINQ queries returning bool to one returning bool?
- How do I combine these similar linq queries into one?
- How do i combine 2 Linq queries into 1?
- A better way to combine two Linq Queries into one in MVC5 Controller
- How can I combine these linq queries into one?
- Combine LINQ queries
- Combine "WHERE" queries with LINQ
- How to combine two linq queries using Union
- Union two models together causes "The specified LINQ expression contains references to queries that are associated with different contexts."
- Combine queries with LINQ
- How can I dynamically combine a set of LINQ queries at runtime?
- Using LINQ to combine the results of 2 queries
- Is it possible to combine 2 view models, each populated with 2 different LINQ queries and return to 1 view?
- How to combine results from multiple linq queries and then sort?
- Combine two queries in linq
- Combine similar LINQ queries
- How to combine linq queries and selecting distinct records?
- Combine 2 LINQ queries into 2
- How to combine 2 LINQ XML queries in C#
- Combine two LINQ group by queries
- How to combine collection of linq queries into a single sql request
More Query from same tag
- Cannot convert lambda expression VB .net to C#
- Using Linq Correct Quiz and Group by Topic
- XML To Dictionary
- Convert if and foreach statement to select and where in linq
- How can I set LINQ SelectMany projection via Func parameter?
- When I try to write to a List my Previous text in there gets Overwritten
- Retrieving current timestamp of the database
- LinQ optimization
- How to get SQL query into LINQ form in C# code
- Match Table Header To String inside LINQ
- Linq ObservableCollection return no result
- LINQ Select statement with EF - object initializer reuse assignment
- linq with max date in sub query
- LINQ not evaluating check for null object
- Compare part of stringdate in string to datetime in C#.NET using LinQ
- Linq Query ignore empty parameters
- Move item to first in array
- How to evaluate a standalone boolean expression in a LINQ expression tree
- LINQ how to return group by as List?
- How to do partial search on multiple keys dictionary
- Summing linq data by year
- Error Cannot implicitly convert type 'string' to 'int' - for the iterator in a ForEach loop
- How can this query be improved?
- Updating XML nodes from an object list in C#
- Subtract a generic list from another
- .Net EF AddRange On List of Objects is Showing as Multiple Queries
- Issue with two identical services
- LINQ: how to transform list by performing calculations on every element
- Translating WITH ROLLUP SQL statement to LINQ
- C# Linq / How to write below code in single query?