SQL 数据服务 - 查询 null
(这与 Microsoft 的 SitkaSoapService 相关,位于 https://database.windows.net/soap 的服务参考中/v1/)
我正在使用 SitkaSoapServiceClient 通过 SOAP 访问我的 SQL Data Services 数据库。
我可以通过在字符串中传递 linq 语句来查询数据,例如:
Scope scope = new Scope();
scope.AuthorityId = authorityId;
scope.ContainerId = containerId;
using (SitkaSoapServiceClient proxy = GetProxy())
return proxy.Query(scope, "from e in entities where e[\"FirstName\"] == \"Bob\" select e");
但是,我无法弄清楚如何查询空属性值(即查找没有该属性的实体)。
我希望能够说:
return proxy.Query(scope, "from e in entities where e[\"FirstName\"] == null select e");
...但这会引发 FaultException<>
,说“找不到名称 'null'”
有什么想法吗?
(This relates to Microsoft's SitkaSoapService, in the service reference at https://database.windows.net/soap/v1/)
I'm using SitkaSoapServiceClient to access my SQL Data Services database by SOAP.
I can query data by passing a linq statement in a string, such as:
Scope scope = new Scope();
scope.AuthorityId = authorityId;
scope.ContainerId = containerId;
using (SitkaSoapServiceClient proxy = GetProxy())
return proxy.Query(scope, "from e in entities where e[\"FirstName\"] == \"Bob\" select e");
However, I can't figure out how to query for a null property value (i.e. find entities without that property).
I'd expect to be able to say:
return proxy.Query(scope, "from e in entities where e[\"FirstName\"] == null select e");
... but that throws a FaultException<>
, saying "The name 'null' could not be found"
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以像这样检查 not null:
因此 null 检查变得:
有点令人讨厌,但它有效。 也许有更好的方法,但我找不到......
You can check for not null like this:
so the null check becomes:
A bit nasty, but it works. Maybe there's a better way, but I can't find it...
我不熟悉您正在尝试的服务,但 T-SQL 需要类似的东西:
I'm not familiar with the service you are trying but T-SQL would want something like: