score:1
take a look at the answer i gave for this question:
score:2
i think i'd use extension methods on ienumerable instead of dynamic linq.
var result = from v in users
join d in orders on v.userid equals d.userid
where v.username.contains(username)
where v.firstname.equals(firstname)
where v.zipcity.equals(zipcity)
where v.orderdate >= orderdate && v.orderdate < orderdate
select v.email, v.shippingcity, v.trackingno, d.productid;
if (!string.isnullorempty(productname))
{
result = result.join( products.where( p=> p.productname == productname ),
d => d.productid,
p => p.productid,
(d,p) => new
{
d.email,
d.shippingcity,
d.trackingno
});
}
Source: stackoverflow.com
Related Query
- Can i do this with dynamic LInq or is there a better way - Linq, C#, VS2008
- Is there a better way to achieve this with Linq or a better code
- Is there a better way to code this LINQ fragment?
- Is there a more clear and concise way to express this statement with better LINQ?
- Is there a better or more efficient way to filter with linq
- Is there a better way to do this, maybe replace the for/foreach loop with something LINQ ish?
- Is there a better way of shortening this LINQ statement?
- Is there a better way of writing this Linq Query
- is there a better way to write this frankenstein LINQ query that searches for values in a child table and orders them by relevance?
- Is there any way to encapsulate a simple LINQ query in an extension method that can be used with LINQ to Entities query?
- Is there a better way to do this LINQ statement block?
- How to code this LINQ query in a better way
- Linq to SQL with GroupBy and Detail - Is there a better way to do this?
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- Is there a better way to code this Duplicate ID Checker?
- Is there a better way to write this LINQ query?
- Is there a way I can do a foreach that contains code in a LINQ expression?
- Is there a way to do this with a LINQ Query?
- Is there a better way to do this Linq query and function?
- Is there a better way of calling LINQ Any + NOT All?
- Is there some sort of syntax error with this LINQ JOIN?
- Is there a better way to split this string using LINQ?
- How can I build Linq query with dynamic OR statements?
- Is there a way to simplify this linq
- Is there a better way to set a property common to a list of items in linq
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Is there a better way to combine these two Linq expressions?
- How can I create a dynamic LINQ query in C# with possible multiple group by clauses?
- Better way to cleanly handle nested XML with LINQ
- How can I combine this code into one or two LINQ queries?
More Query from same tag
- Using the less than comparison operator for strings in F#
- How to populate my base Customer with EF
- Can you set/update a value in real-time within a LINQ statement during iteration?
- How group elements in LINQ to get result like Facebook messages
- Concatenating LINQ query results when using loops
- how to select top 1 from each group after order by
- LINQ subquery "NOT IN" problem
- Possible to do two Group Bys and an if count check in one LINQ lambda statement?
- How to handle null value?
- LINQ: Enumerate through duplicates in List and remove them
- Any better way for converting array to concurrent dictionary using linq or IEnumerable?
- Unable to pull fields from within LINQ query
- SUM on multiple separate columns in LINQ
- Linq Lambda join breaks when joining a table
- System.OutOfMemoryException on Linq Joins
- Is it possible to convert this SQL query to linq?
- Trying to find some Tags via a collection of where clauses in .NET Linq
- LINQ Query returning null results into anonymous variable
- LINQ vb.net GROUP BY - SELECT JOINED column
- Is there a better way to get sub-sequences where each item matches a predicate?
- Nested group results in too many hits on the server
- Try to get total price with id from 2 tables with Linq
- Recommended programming pattern for multiple lookups
- Sort in-memory list by another in-memory list
- Comparing 2 string arrays using Linq and Regex for a partial match
- How can I generate this property implementation using Expressions instead of emitting IL?
- how to convert from sql query to linq
- LINQ to SQL - How to efficiently do either an AND or an OR search for multiple criteria
- LINQ to DataSet Query Help
- using group by in linq nested list c#