2012-05-04 67 views
0

我想查詢其中該列IS NULL記錄可空類型:比較WHERE的LINQ子句SQL VB.NET

Dim UnassignedSubSvc = 
(From c In CurrentContext.SubService 
Where c.Product.ProductSubServiceId **is null** 
Select c).ToList() 

回答

1
Dim UnassignedSubSvc = 
(From c In CurrentContext.SubService 
Where Not c.ProductSubServiceId.HasValue 
Select c).ToList() 

可空類型使用HasValue來表示它們含有非空值,所以簡單否定就足夠了。

+0

嗨,我得到的錯誤HAsvalue不是整數 – BumbleBee

+0

的成員然後你的'ProductSubServiceId'沒有設置爲可以在元數據文件(.EDMX文件)爲空。修復你的數據庫模式。 – Blindy

+0

ProductSubServiceID是表中的refertial鍵。 – BumbleBee