EF does not know how to convert a C # method to SQL code.
If you change this, it should work: (Note that I added ".ToList ()")
var results2 = objectSet.ToList().Where(doc=>System.Data.Objects.SqlClient.SqlFunctions.DataLength( doc.BINARYCONTENT)>50000); Assert.IsTrue(results2.ToList().Count == 9); var results3 = db.DOCUMENTS.ToList().Where(doc => System.Data.Objects.SqlClient.SqlFunctions.DataLength(doc.BINARYCONTENT) > 50000); Assert.IsTrue(results3.ToList().Count == 9);
When you declare a variable as an EF request, it does not actually start until it is enumerated. By listing it to the list before you run the where clause, it will run the Where clause, which will be executed on the CLR objects, instead of EF trying to execute as part of the db request.
source share