여기에 빠른 질문이 있습니다. 먼저 EF6 모델을 사용하십시오.오류 : 엔티티에 LINQ가 메서드를 인식하지 못합니다. 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);
첫 번째 어설 션이 성공하므로 결과 2와 결과 3이 실행될 때 왜 다음 예외가 발생합니까?
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.
다른 어설 션이 성공하려면 어떤 방법이 있습니까?
내에 위치한
를 사용한다 그것의 지금은 거의 일주일이었다. 나는이 질문이 얼마나 오래 되어도 제안을 듣는 데 관심이 있습니다. –