Dynamically building LINQ expression predicates(albahari.com)

submitted by powerrushpowerrush(3873) 4 years, 2 months ago

Suppose you wanted to write a LINQ to SQL query that implemented a keyword-style search. In other words, a query that returned rows whose description contained some or all of a given set of keywords...

2 comments |category: |Views: 901

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by cls2degcls2deg(1535) 4 years, 2 months ago 0

The only problem with the code presented in this article is that the predicates use Or and And instead of OrElse and AndAlso. The latter two should be use to provide boolean short-circuiting. Otherwise, every clause of a predicate will be executed each time it's invoked.

Reply

posted by powerrushpowerrush(3873) 4 years, 2 months ago 0

Meaning you could just replace Expression.Or with Expression.OrElse & Expression.And with Expression.AndAlso to solve the issue you point out?

Reply

information Login or create an account to comment on this story