How to use “contains” or “like” in a dynamic linq query?

Here is the answer! The Dynamic Linq does support the . operator, According to the docs: “Instance field or instance property access. Any public field or property can be accessed.” Thus, it is possible to use this syntax .Where(“MyColumn.Contains(@0)”, myArray) Thanks for all the suggestions! And thanks to me for finding the solution.

LINQ to Entities does not recognize the method ‘System.TimeSpan Subtract(System.DateTime)’ method

You could use the EntityFunctions.DiffDays method EntityFunctions.DiffDays(product.EventDate, DateTime.Now) //this will return the difference in days UPDATE EntityFunctions is now obsolete so you should use DBFunctions instead. System.Data.Entity.DbFunctions.DiffDays(product.EventDate, DateTime.Now)

Calling a method inside a Linq query

You have to execute your method call in Linq-to-Objects context, because on the database side that method call will not make sense – you can do this using AsEnumerable() – basically the rest of the query will then be evaluated as an in memory collection using Linq-to-Objects and you can use method calls as expected: … Read more

How to move from Linq 2 SQL to Linq 2 Entities?

To show the created SQL commands for debugging in EF using System.Data.Objects; … var sqlQuery = query as ObjectQuery<T>; var sqlTrace = sqlQuery.ToTraceString(); AFAIK there are no commands to create DB’s or do any sort of DDL work. This is design limitation of the “Entity SQL” language The EDMX design surface will map your current … Read more

How to use union all in LINQ?

Concat is the LINQ equivalent of UNION ALL in SQL. I’ve set up a simple example in LINQPad to demonstrate how to use Union and Concat. If you don’t have LINQPad, get it. In order to be able to see different results for these set operations, the first and second sets of data must have … Read more

Using contains() in LINQ to SQL

Looking at the other attempts saddens me 🙁 public IQueryable<Part> SearchForParts(string[] query) { var q = db.Parts.AsQueryable(); foreach (var qs in query) { var likestr = string.Format(“%{0}%”, qs); q = q.Where(x => SqlMethods.Like(x.partName, likestr)); } return q; } Assumptions: partName looks like: “ABC 123 XYZ” query is { “ABC”, “123”, “XY” }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)