2014-02-14 40 views
1

我試圖使用十進制數據類型來創建一個Predicate,但我得到了以下錯誤:微風:使用謂詞用十進制數據類型

Error retrieving data.A binary operator with incompatible types was detected. 
Found operand types 'Edm.Decimal' and 'Edm.Double' for operator kind 'Equal'. 
Error: A binary operator with incompatible types was detected. Found operand types 
'Edm.Decimal' and 'Edm.Double' for operator kind 'Equal'. 

下面是代碼,我有嘗試它

// engineSize equals 1.4 in this case. 
predicate.create('engineLitreCapacity', '==', engineSize); 
+1

對於同樣的問題,在這裏有很好的答案[在此鏈接] [1]。由於 [1]:http://stackoverflow.com/questions/27609998/breeze-predicate-for-decimal-type/27611461#27611461 – sergio

回答

1

您需要parseFloatengineSize

predicate.create('engineLitreCapacity', '==', parseFloat(engineSize)); 
+0

我試過了,但仍然得到了同樣的錯誤:/ – CallumVass

1

什麼是DAT 'engineLitreCapacity'的元數據中是否包含atype,並且它是否與您的數據庫上的數據類型匹配相同的字段?如果不是,您的元數據是如何通過FetchMetadata調用進行初始化的,還是手動創建的?

2

我有同樣的問題。我發現了謎:)...我認爲這是在出頭命名有關的元數據和REST服務控制器符號約定:如:

不工作

/*Breeze Controller Server Side*/ 
     [HttpGet] 
      public IQueryable<Product> Items() 
      { 
       return _contextProvider.Context.Products; 
      } 

    /*Client*/ 
    query = breeze.EntityQuery 
         .from("Items") 
         .where(Predicate.create('BasePrice', >', 1) 
         .orderBy(sortString) 
         .select(selectData) 
         .skip(skip) 
         .take(take) 
         .inlineCount(); 

它的作品!

/*Breeze Controller Server Side*/ 
[HttpGet] 
    public IQueryable<Product> Products() 
    { 
     return _contextProvider.Context.Products; 
    } 

/*Client*/ 
query = breeze.EntityQuery 
       .from("Products") 
       .where(Predicate.create('BasePrice', >', 1) 
       .orderBy(sortString) 
       .select(selectData) 
       .skip(skip) 
       .take(take) 
       .inlineCount();