Solved

Using variable in Linq query

Posted on 2011-02-16
1
600 Views
Last Modified: 2013-11-11
I'm trying to do something like this in Linq To Entities:
string criteria = FuncToCalcCriteria();
“Select * from tablename where SomeField “  + criteria;//could be >< <>= etc.etec.
? I'm getting 'Method cannot be translated into a store expression' if I put the method into the Linq, but I can't concatenate expressions like you do in SQL strings, so is there a way round?
0
Comment
Question by:Silas2
1 Comment
 
LVL 21

Accepted Solution

by:
naspinski earned 250 total points
ID: 34906466
The Dynamic LINQ library has you covered:

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

Scott Guthrie explains it better than I ever could.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now