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 Articles
- 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
- How to randomly add data from a database to a button's text attribute
- Why does ReSharper tell me "implicitly captured closure"?
- Searching data in a list using linq
- Can this be done in one line with Linq?
- How to get the difference of two list in C# using LINQ
- Using LINQ to SQL to perform an update/set
- linq with unassigned variable parameters
- LINQ to Entities - updating binary field
- NHibernate 3.1 Linq with Contains and Any
- Improve db4o linq query
- need a simple linq
- LINQ won't sum a group with a float? property
- Error in LINQ (column doesn't exist) when using Entity Framework
- Date format in LINQ
- Numbering - algorithm in a 2d array - "assign occurrence of a letter" - in c#
- Performing Sum() Operation in LINQ
- Sort part of a list in descending order (by date), the other part in ascending order (alphabetically)?
- Why does a null string concatenated to a non null string evaluate to null?
- Get records from table and related related table using Linq to entity
- I dont know how to do order by in linkq with multiple table