How to create LINQ Expression Tree to select an anonymous type

This can be done, as mentioned, with the help of Reflection Emit and a helper class I’ve included below. The code below is a work in progress, so take it for what it’s worth… ‘it works on my box’. The SelectDynamic method class should be tossed in a static extension method class. As expected, you … Read more

How many Include I can use on ObjectSet in EntityFramework to retain performance?

A query with includes returns a single result set and the number of includes affect how big data set is transfered from the database server to the web server. Example: Suppose we have an entity Customer (Id, Name, Address) and an entity Order (Id, CustomerId, Date). Now we want to query a customer with her … Read more

‘Date’ is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported

If you are using EF 6.0+, you can use DbFunctions.TruncateTime(DateTime?) : var query = from t in context.Logs where t.Title == title && DbFunctions.TruncateTime(t.Timestamp) == LogDate.Date select t; Note: For earlier version of EF where DbFunctions isn’t available, EntityFunctions.TruncateTime(DateTime?) can be used instead.

C# PredicateBuilder Entities: The parameter ‘f’ was not bound in the specified LINQ to Entities query expression

I ran across the same error, the issue seemed to be when I had predicates made with PredicateBuilder that were in turn made up of other predicates made with PredicateBuilder e.g. (A OR B) AND (X OR Y) where one builder creates A OR B, one creates X OR Y and a third ANDs them … Read more

How do I perform Date Comparison in EF query?

Use the class DbFunctions for trimming the time portion. using System.Data.Entity; var bla = (from log in context.Contacts where DbFunctions.TruncateTime(log.ModifiedDate) == DbFunctions.TruncateTime(today.Date) select log).FirstOrDefault(); Source: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/84d4e18b-7545-419b-9826-53ff1a0e2a62/

Is LINQ to SQL deprecated?

For all the “Linq-to-SQL is dead” folks: Scott Guthrie himself clearly mentioned at TechEd Europe that Linq-to-SQL is FULLY SUPPORTED in .NET 4, and Damien Guard posted a blog post on what changes and improvements have been made for Linq-to-SQL in .NET 4. To quote Mark Twain: “Reports of my death have been greatly exaggerated”……

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