[英]Entity Framework 'ArrayIndex' is not supported in LINQ to Entities
in my SQL Server DB table, I have the binary
column type. 在我的SQL Server数据库表中,我有binary
列类型。
I can't execute the query, why ? 我无法执行查询,为什么?
var data = (from x in model.MyTable
where x.BinaryColumn[0] == 1
select x).FirstOrDefault();
I get the The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities
error 我得到The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities
错误The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities
These expressions are translated to SQL queries, and this is one of the things you cant do. 这些表达式被转换为SQL查询,这是您无法做到的事情之一。 Take a look here for more detail: LINQ To Entities doesn't recognize array index 请查看此处了解更多详细信息: LINQ To Entities无法识别数组索引
In TSQL the SUBSTRING function can be used on binary
/ varbinary
. 在TSQL中, SUBSTRING函数可用于binary
/ varbinary
。
Somewhere define: 在某处定义:
[DbFunction("SqlServer", "SUBSTRING")]
public static byte[] SubString(byte[] field, int start, int length)
{
throw new NotSupportedException("Direct calls are not supported.");
}
then 然后
var data = (from x in model.MyTable
where Substring(x.BinaryColumn, 1, 1) == new byte[] { 1 }
select x).FirstOrDefault();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.