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
- how to build Expression<Func<x,y>> with no input parameters?
- linq vs ToDictionary() and TryGetValue() - what is more efficient?
- Combining expression trees
- C# type arguments cannot be inferred from usage in Select with multiple returns
- Executing Actions within Actions for collection without creating new collection
- Entity Framework filter on inner list
- Select all messages but not if the subject id is the same
- GroupBy with predefined type using Linq
- c# - LINQ find 2D jagged array minimum, return index
- convert sql to ling group by and average between 2 dates when end date can be null
- How to create this Linq function?
- How to combine conditions dynamically?
- Linq Select many where property x exists in externalList
- Using TryGetValue() in LINQ?
- LINQ verify row of dates and their values
- Combinations without repetition with specific number
- If getHashCode() for string or integer is not guaranteed to be unique why use it?
- query to Combine all childlist of all parent objects in one collection
- How to join two List<string> in c# using LINQ
- EF6: Full-text Search with Database First Approach
- How to "prefix" order by expression using dynamic-linq
- Checking if an entity is null after linq queries
- Nested foreach to change list items
- linq query comparing Dates within a list
- How to create one collection by combining data from two collections?
- Combine two sequences with different types
- How I keep entity object after DataContext disposed?
- Passing value from one model to another in a ViewModel
- How can I sort by a column that is included in a new{} section of a LINQ query?
- Linq expression with Join, and conditional OrderBy / OrderByDescending