如何获得使用LINQ到实体的字节数组的长度? [英] How to get a byte array length using LINQ to Entities?
问题描述
我有保存该文件作为字节数组的数据文档类。
我需要检查数组的大小,使用LINQ到实体。
I have a Document class that stores the data of that document as a byte array. I need to check the size of the array, using LINQ to Entities.
我曾尝试以下内容:
[long Linq query here...] o.Data.Length < 800000)
问题是我得到以下异常:
The problem is I get the following exception:
在LINQ前pression节点类型'ArrayLength'不是在LINQ支持实体。
The LINQ expression node type 'ArrayLength' is not supported in LINQ to Entities."
有没有其他的方法来检查字节数组的大小?
Is there any other way to check the size of the byte array?
推荐答案
使用<一个href=\"http://msdn.microsoft.com/en-us/library/dd466174%28v=vs.110%29.aspx\"><$c$c>SqlFunctions.DataLength方法(Byte []) 比较长。
Use SqlFunctions.DataLength Method (Byte[])
to compare length.
yourquery..... SqlFunctions.DataLength(o.Data) < 800000)
请参阅: Linq2EF陷阱:使用长度属性将导致System.NotSupportedException
这篇关于如何获得使用LINQ到实体的字节数组的长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!