2013-05-02 67 views
0

我有問題,不知道該怎麼辦。有一個mvc項目,並在我的控制器中創建我的linq查詢來訪問我的數據。但是我更新了一些數據,並且有0或值。我如何處理我的linq查詢?特別是d.direct有一些0值。我試着使用的情況下,當語句,但是當網頁被顯示在控制器中處理空值

這裏沒有工作是錯誤信息在存儲過程中處理:

Line 2005:    get { 
Line 2006:     try { 
Line 2007:      return ((double)(this[this.tableFactSpendingByIndustry.EmplDirectColumn])); 
Line 2008:     } 
Line 2009:     catch (global::System.InvalidCastException e) 
var rows = from d in dt 
      select new object[] { 
       string.Empty,//+ 
       d.industry_code.ToString(), 
       d.industry_desc,//description             
       string.Format("{0:C1}",DoD/cScale),//spending millions              
       string.Format("{0:N0}",d.Direct),//direct 
       string.Format("{0:N0}",d.Indirect),//indirect 
       string.Format("{0:N0}",d.Induced),//induced 
       string.Format("{0:C0}", Math.Round(Wage,0)),//avg ann wage 
       d.nextLevelMin.ToString(), 
       d.nextLevelMax.ToString(),                 
      };//end select statement 

      return Json(new 
      {     
       iTotalRecords = dt.Count(), 
       aaData = rows 
      }, //end json return statement 
      JsonRequestBehavior.AllowGet); 
+0

什麼問題?你有錯誤嗎?顯示(或不顯示)的東西,你不會指望? – 2013-05-02 20:54:50

+0

這是在conosle中的錯誤: Line 2005:get 2006 2006:try try { Line 2007:return((double)(this [this.tableFactSpendingByIndustry.EmplDirectColumn])); Line 2008:} Line 2009:catch(global :: System.InvalidCastException e){ – 2013-05-02 20:58:02

+0

其他方式使用該查詢的數據表不會填充 – 2013-05-02 20:59:18

回答

1

你必須這樣做:

d.nextLevelMin != null ? d.nextLevelMin.ToString() : string.empty