Search code examples
c#angularjsasp.net-web-apibreezebreeze-sharp

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. Using BreezeJs and ASP.NET WebAPI(Breeze Server Side) with 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:

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

The $scope.filter.serialNumber is a string and serialNumber is a GUID property

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&)

Note the snippet:

(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


Solution

  • I had the same issue when comparing userId in Breeze query. Breeze appends 'guid' in the OData query.

    I was able to fix this issue by appending .toType("entityTypeName") to the breeze query.

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