score:1

Take a look at the answer I gave for this question:

Best Practices for Building a Search App?

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
                                  });
}

Related Articles