score:11
Accepted answer
When doing comparisons you need two ==
and also in order to avoid injection use the following overload:
var result = db.Persons.Where("surname == @0", "bob");
Also I would recommend you downloading and looking at the examples provided with the product you are using. Scott Gu has also blogged about it.
score:5
var result = db.Persons.Where("surname == \"bob\"");
would work, though you should make sure whatever bob really is is properly escaped too.
That said, you would do better to have something like this:
String bob = "bob"; // or whatever
var result = from p in db.Persons p
where p.surname = bob
select p
Source: stackoverflow.com
Related Query
- Dynamic query with LINQ won't work
- How can I build Linq query with dynamic OR statements?
- LINQ TO SQL, Dynamic query with DATE type fields
- Dynamic linq query with multiple/unknown criteria
- linq query with dynamic predicates in where clause joined by OR
- Using LINQ Dynamic Query Library with Dictionary<string, object> and .AsQueryable()
- How can I create a dynamic LINQ query in C# with possible multiple group by clauses?
- How to build a nested query with the dynamic LINQ library
- How to dynamic add filters to a LINQ query against an Odata Source in C#
- Retrieve and print data from dynamic sql query with linq
- Issues with DateTime.AddMinutes() in Dynamic LINQ Query
- Query dynamic data with LINQ
- Linq sub query when using a repository pattern with EF code first
- MVC Linq Query with dynamic column name in WHERE clause
- LINQ Query Field<T> with dynamic type
- Linq query with MongoDB works does not work as Func
- Need help with a LINQ Query using the Dynamic LINQ Library
- LINQ Dynamic Query with group by and string variable
- Dynamic linq query with nested groups
- Implementing Dynamic LINQ Query with "NOT IN" Clause
- LINQ Query with dynamic number of boolean ANDs
- Avoiding repeating code with Linq query + optional params
- Linq Query with dynamic type
- Linq query to db with dynamic where parameters
- dynamic linq query - OrderBy with properties that are null
- how to write a Linq query with a EF code first Many to Many relationship
- Linq Dynamic Query Issue - Operator '&&' incompatible with operand types 'String' and 'Boolean'
- Left join with linq query does not work with null columns in datatable
- Run LINQ query with dynamic table name
- LINQ dynamic query with Where clause
More Query from same tag
- Accessing a field of a class after a lambda expression
- Is there a java lambda expression equivalent of the C# linq let?
- remove tuple from list using linq
- MVC linq keeps returning the last row of data
- linq group by two columns and get only rows with same group by values
- Dynamically building an expression tree
- How to get inner values from XML
- LINQ groupby with condition dependent on other sequence elements
- LINQ On DataTables With Multiple Conditions
- How to check null object in dynamic linq on th fly?
- How to get properties of a type inside an object
- LINQ only returns one item in collection
- How to remove selected data that found on another list and take last 6 id through LINQ without foreach loop
- Convert a List<T> to a nested Dictionary<string, Dictionary<string, T>
- Case-insensitive "contains" in Linq
- Why this linq query returns only first attribute?
- The LINQ expression could not be translated while trying to sort
- Linq outer join and group by with count in select
- Reorder by original index when using Linq
- How to use LINQ to sort custom items by using StartWith
- select two properties in an array of obj
- Merge two lists but choose one with higher property value c#
- Calling .Distinct() on enumerables of enumerables
- Group by with average in LINQ
- How to populate complex model with linq when datatables are different
- Efficient linq query to return objects when you have a list of object id's
- Calculation did not perform to calculate the difference in total days between 2 dates in c#asp.net sql linq
- If list.Find() returns null.code returning exception
- What datastructure would you use to represent this format of data?
- Linq OData "Where" clause on nested list