简体   繁体   English

检测到具有不兼容类型的二元运算符。找到操作数类型edm.string和edm.guid用于种类相等

[英]A binary operator with incompatible types was detected. Found operand types edm.string and edm.guid for kind equal

I implementing a filter using breeze predicate. 我使用breeze谓词实现过滤器。 Using BreezeJs and ASP.NET WebAPI(Breeze Server Side) with Entity Framework 使用BreezeJs和ASP.NET WebAPI(Breeze Server Side)和Entity Framework

The predicate looks like this: 谓词看起来像这样:

 var predicate = breezeProvider.breeze.Predicate.create('serialNumber', '==', $scope.filter.serialNumber); predicates.push(predicate); 

When I execute the query. 当我执行查询。 Breeze throw an exception with the following messages: Breeze使用以下消息抛出异常:

A binary operator with incompatible types was detected. 检测到具有不兼容类型的二元运算符。 Found operand types edm.string and edm.guid for kind equal 找到操作数类型edm.string和edm.guid用于种类相等

The $scope.filter.serialNumber is a string and serialNumber is a GUID property $ scope.filter.serialNumber是一个字符串,serialNumber是一个GUID属性

The url is as follow. 网址如下。

http://localhost:51969/breeze/WarehouseProductTransactions/GetProducts ?$filter=(StatusId ne 3d) and (WarehouseId eq 1d) and (AuthorizedADUserId eq 'bTdbnW8t6Uu4D4KHCoQOhg==') and (SerialNumber eq guid'1b9d065e-eb48-4f3d-883c-2c841771a3e8')&$orderby=Id&$top=5&$expand=Inventory,AuthorizedADUser&$inlinecount=allpages&) http:// localhost:51969 / breeze / WarehouseProductTransactions / GetProducts ?$ filter =(StatusId ne 3d)and(WarehouseId eq 1d)and(AuthorizedADUserId eq'bTdbnW8t6Uu4D4KHCoQOhg ==')和(SerialNumber eq guid'1b9d065e-eb48-4f3d- 883C-2c841771a3e8' )&$的OrderBy =编号&$顶部= 5&$扩大=库存,AuthorizedADUser&$ inlinecount =所有页&)

Note the snippet: 请注意代码段:

(SerialNumber eq guid'1b9d065e-eb48-4f3d-883c-2c841771a3e8') (SerialNumber eq guid'1b9d065e-eb48-4f3d-883c-2c841771a3e8')

My server side is as follow: 我的服务器端如下:

[EnableBreezeQuery(MaxNodeCount = 200)]
public IQueryable<WarehouseProductTransactionDetail> GetProducts()
{
    return _contextProvider.Context.WarehouseProductTransactionDetails;
}

I'm trying to figure out how I can resolve this situation but no idea. 我试图找出如何解决这种情况,但不知道。

Any help is appreciated 任何帮助表示赞赏

I had the same issue when comparing userId in Breeze query. 在Breeze查询中比较userId时遇到了同样的问题。 Breeze appends 'guid' in the OData query. Breeze在OData查询中附加'guid'。

I was able to fix this issue by appending .toType("entityTypeName") to the breeze query. 我能够通过将.toType("entityTypeName")附加到breeze查询来解决此问题。

let query = new breeze.EntityQuery().from('orders');          
let predicate = breeze.Predicate.create("CreatedBy", "==", userId);


query = query.where(predicate).toType("Order");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检测到类型不兼容的二元运算符。 找到运算符类型“Equal”的操作数类型“Edm.Guid”和“Edm.String” - A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal' 此操作的参数类型&#39;Edm.DateTime&#39;和&#39;Edm.String&#39;不兼容 - The argument types 'Edm.DateTime' and 'Edm.String' are incompatible for this operation 此操作的参数类型&#39;Edm.Int16&#39;和&#39;Edm.String&#39;不兼容 - The argument types 'Edm.Int16' and 'Edm.String' are incompatible for this operation 参数类型'Edm.String'和'Edm.Int32'与此操作不兼容 - The argument types 'Edm.String' and 'Edm.Int32' are incompatible for this operation System.Data.EntitySqlException:参数类型&#39;Edm.String&#39;和&#39;Edm.Int32&#39;与此操作不兼容 - System.Data.EntitySqlException: The argument types 'Edm.String' and 'Edm.Int32' are incompatible for this operation 无法将类型为System.String的值转换为OData类型[Edm.Guid Nullable = True] - Unable to convert value of type System.String to OData type [Edm.Guid Nullable=True] OData DateTime过滤器Edm.String错误? - OData DateTime filter Edm.String error? 运算符&#39;==&#39;与使用DynamicExpression.ParseLambda的操作数类型&#39;Guid&#39;和&#39;Guid&#39;不兼容<T, bool> - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> MappingException Edm.String与SqlServer.varbinary不兼容 - MappingException Edm.String not compatible with SqlServer.varbinary 出现错误:未为类型&#39;System.Guid&#39;和&#39;System.String&#39;定义二进制运算符Equal - Getting error : The binary operator Equal is not defined for the types 'System.Guid' and 'System.String'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM