2009-02-26 72 views
0

(這涉及到微軟的SitkaSoapService,在服務引用在https://database.windows.net/soap/v1/SQL數據服務 - 查詢空

我使用SitkaSoapServiceClient通過SOAP訪問我的SQL數據服務數據庫。

我可以在一個字符串傳遞一個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<>,說:「‘空’的名稱無法找到」

任何想法?

回答

1

您可以檢查NOT NULL這樣的:

where e["FirstName"] >= "" 

所以空檢查成爲:

where !(e["FirstName"] >= "") 

有點討厭,但它的作品。也許有更好的辦法,但我找不到它...

-1

我不熟悉您正在嘗試,但T-SQL會想是這樣的服務:

return proxy.Query(scope, "from e in entities where e[\"FirstName\"] IS null select e"); 
+0

除了linq的整個點是能夠避免SQL語法... – dkretz 2009-02-26 23:00:55