A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator type 'equals'


prisoner zero

I get the following exception when calling OData from Kendo ListView:

"Binary operators with incompatible types detected. Operand types 'Edm.Guid' and 'Edm.String' found for operator type 'Equal'"

Decoded filter:
$filter=OrganizationId eq'4c2c1c1e-1838-42ca-b730-399816de85f8'

Encoded filter:
%24filter=OrganizationId+eq+%274c2c1c1e-1838-42ca-b730-399816de85f8%27

Haven't tried these filters successfully yet:
$ filter = OrganizationId eq guid '4c2c1c1e-1838-42ca-b730-399816de85f8'
$ filter = OrganizationId eq cast('4c2c1c1e-1838-42ca-b730-399816de85f8', Edm.

My Web API call looks like this:

// GET: odata/Sites
[HttpGet]
[EnableQuery]
public IHttpActionResult GetSites(ODataQueryOptions<Site> queryOptions)
{
    IQueryable<Site> sites = null;

    try
    {
        queryOptions.Validate(_validationSettings);
        sites = _siteService.GetAll().OrderBy(x => x.SiteName);

        if (sites == null)
            return NotFound();
    }
    catch (ODataException ex)
    {
        TraceHandler.TraceError(ex);
        return BadRequest(ex.Message);
    }

    return Ok(sites);
}

My JAVASCRIPT KENDO datasource looks like:

var dataSource = new kendo.data.DataSource({

    filter: { field: "OrganizationId", operator: "eq", value: that.settings.current.customer.id },
    schema: {
        data: function (data) {
            return data.value;
        },
        total: function (data) {
            return data.length;
        }
    },
    serverFiltering: true,
    serverPaging: true,
    transport: {
        parameterMap: function (options, type) {

            var paramMap = kendo.data.transports.odata.parameterMap(options);

            // Remove invalid Parameters that Web API doesn't support
            delete paramMap.$inlinecount; // <-- remove inlinecount
            delete paramMap.$format; // <-- remove format
            delete paramMap.$callback; // <-- remove callback

            // PLEASE NOTICE: That I have tried reformatting unsuccessfully
            //paramMap.$filter = paramMap.$filter.replace("OrganizationId eq ", "OrganizationId eq guid");
            //paramMap.$filter = "OrganizationId eq cast('81de6144-987c-4b6f-a9bd-355cb6597fc1', Edm.Guid)";

            return paramMap;
        },
        read: {
            url: buildRoute('odata/Sites')
            , dataType: 'json'
        }
    },
    type: 'odata'
});
Yi Ding - MSFT

If the protocol version of the OData service is V4, the correct query URL should be:

$filter=OrganizationId eq 4c2c1c1e-1838-42ca-b730-399816de85f8

Single quotes are not required.

Related


Operand Types of Binary AND Operator

username Which type of operator uses the logical AND operator (&)? I need to input AND shorts aand a "number" mfrom 1 to 16 and get another short b. That primitive type must be m? example: ? m = ...; //with 1 <= m <= 16 short a = 2; short b = a & m; The examp

Operand Types of Binary AND Operator

username Which type of operator uses the logical AND operator (&)? I need to input AND shorts aand a "number" mfrom 1 to 16 and get another short b. That primitive type must be m? example: ? m = ...; //with 1 <= m <= 16 short a = 2; short b = a & m; The examp

Operand type is incompatible with operator

Noppadet i get error Operand type is incompatible with operator Click OK in the header when trying to compare two "real" data types. Can anyone help me with what problem? public void clicked() { real localAnnualUsage = itemSetup_DS.AnnualUsage();

Operand type is incompatible with operator

Noppadet i get error Operand type is incompatible with operator Click OK in the header when trying to compare two "real" data types. Can anyone help me with what problem? public void clicked() { real localAnnualUsage = itemSetup_DS.AnnualUsage();