2015-09-04 17 views
0

即時通過數據表jquery和我的頁面做一些mvc.net nhibernate我可以搜索任何字符串如下,但我不能按日期或小數搜索,任何想法如何? 。下面是我試圖和它的成功可以搜索將字符串轉換爲十進制c#mvc

if (!string.IsNullOrEmpty(fm["SearchValue"]) && !string.IsNullOrEmpty(fm["SearchType"])) 

         { 
          criteria.Add(Restrictions.Like(fm["SearchType"], "%" + fm["SearchValue"] + "%")); 

回答

0

嘗試這些用於數字:

criteria.Add(Expression.Between("YourNumber", minValue, maxValue)) 
criteria.Add(Expression.Eq("YourNumber", value)) 

請嘗試以下的日期:

criteria.Add(Expression.Le("YourDate", maxDate)) 
criteria.Add(Expression.Ge("YourDate", minDate) & Expression.Le("YourDate", maxDate)) 

「式」手段「等於」 ,'Le'表示'小於或等於','Ge'表示'大於或等於'。

請參閱針對more examples的NHibernate文檔。 這裏也有關於SO的相關問題。

相關問題