【发布时间】:2018-06-26 16:43:50
【问题描述】:
当我通过 IMobileServiceClient 从我的移动应用程序查询我的 Azure DB 时,我收到以下查询错误:
https://domain.azurewebsites.net/tables/Entities?$filter=(substringof('f',OriginalName) and ((Types and 1) ne 0))&$orderby=Start&$skip=0&$top=20&$select=OriginalName,OriginalSlogan,Description,Start,End,Types,Id,Version,CreatedAt,UpdatedAt,Deleted
The query specified in the URI is not valid. A binary operator with incompatible types was detected. Found operand types 'Edm.Int32' and 'Edm.Int32' for operator kind 'And'."
但是当直接使用查询数据库时
Select * from Entities where ((Types & 1) <> 0)
效果很好。
在Transact-SQL Microsoft Docs 中声明按位和运算符对两个整数(32 位类型)有效。 OData Doc 指出 edm.Int32 表示有符号的 32 位整数值。
我的应用中查询的基本部分是
query = query.Where(f => (f.TypesDb & types) != 0);
f.TypesDb 和 types 在 C# 代码中都是整数。 (注:f.TypesDb通过json序列化映射到Types)
那么为什么类型不兼容呢?
【问题讨论】:
标签: azure tsql xamarin azure-sql-database azure-mobile-services