Ho una domanda veloce qui. utilizzando prima il modello EF6.: LINQ to Entities non riconosce il metodo DataLength
var db = new MyEntities(GetEntityConnectionString());
ObjectContext objectContext = ((IObjectContextAdapter)db).ObjectContext;
ObjectSet<DOCUMENT> objectSet = objectContext.CreateObjectSet<DOCUMENT>();
var results = objectSet.Where("SqlServer.DATALENGTH(it.BINARYCONTENT)>50000");
Assert.IsTrue(results.ToList().Count == 9);
var results2 = objectSet.Where(doc=>System.Data.Objects.SqlClient.SqlFunctions.DataLength(doc.BINARYCONTENT)>50000);
Assert.IsTrue(results2.ToList().Count == 9);
var results3 = db.DOCUMENTS.Where(doc => System.Data.Objects.SqlClient.SqlFunctions.DataLength(doc.BINARYCONTENT) > 50000);
Assert.IsTrue(results3.ToList().Count == 9);
La prima asserzione riesce, quindi perché ottengo la seguente eccezione quando risultati2 e risultati 3 vengono eseguiti?
An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
Additional information: LINQ to Entities does not recognize the method 'System.Nullable`1[System.Int32] DataLength(Byte[])' method, and this method cannot be translated into a store expression.
C'è un modo per ottenere il successo degli altri asseriti?
E 'stata quasi una settimana ormai. Sono ancora interessato a ricevere suggerimenti, non importa quanti anni abbia questa domanda. –