Which SQL Server field type is best for storing price values?

If you’re absolutely sure your numbers will always stay within the range of smallmoney, use that and you can save a few bytes. Otherwise, I would use money. But remember, storage is cheap these days. The extra 4 bytes over 100 million records is still less than half a GB. As @marc_s points out, however, … Read more

LINQ Between Operator

If you express it as a where clause it may just work out of the box with LINQ to SQL, if you can construct an appropriate expression. There may be a better way of doing this in terms of the expression trees – Marc Gravell may well be able to improve it – but it’s … Read more

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