IM試圖使用getValueOrDefault代替空並且不等於1(代碼下面將解釋這一點)&&不能應用於爲bool和INT getvalueordefault
還即時得到的誤差& &不能應用於爲bool和詮釋,我沒有看到這裏的錯誤
string[] arrItems = new string[] { "Laptop", "Workstation", "Mobile","Monitor",,"Other Peripheral","Home Printer","Home Router","Removable Device" };
var tblequipments = from d in db.tblEquipments.Include(t => t.User).Include(t => t.ChangeLog)
where (arrItems.Contains(d.AssetType)) &&
(d.Development.GetValueOrDefault(0)) &&
(d.Deleted == null || d.Deleted != 1) &&
(d.Stock == null || d.Stock != 1) &&
(d.DecommissionDate == Convert.ToDateTime("1900-01-01") || d.DecommissionDate == Convert.ToDateTime("0001-01-01") || d.DecommissionDate == null)
select d;
的錯誤信息是非常不言自明的。 '&&'是一個布爾運算符,它的兩個參數都必須是'bool'。 – Jon
也許GetValueOrDefault()不返回'bool'。 – sharptooth
我想'(d.Development.GetValueOrDefault(0))'這是什麼原因這個問題你爲什麼不這樣做無效和不等於1 –