Edm.Guid Edm.String

Mar 20, 2014 at 3:11 PM
I've created my own model type User with a key type of Guid named Id. I've also copied all customer related files and reworked them to use my new User type. Except for the 'Edit details' link, it all seems to be working. When trying to use the 'Edit details' link an exception is thrown at:
public IQueryable ODataQueryable(ODataQueryOptions<TEntity> oDataQueryOptions)
            return oDataQueryOptions.ApplyTo(_dbSet);
with an exception message of :A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'.

When I break on
 public PageResult<User> GetUser(ODataQueryOptions<User> options)
            var queryable = _userRepository.ODataQueryable(options);

            return new PageResult<User>(
                queryable as IEnumerable<User>, 
and examine options.Filter.RawValue property in my watch window I see: "UserId eq 'c56858b7-95fa-45af-a24a-00e2d6bb9ba7'"

If I edit that value to cast the string to a Guid, like this: "UserId eq guid'c56858b7-95fa-45af-a24a-00e2d6bb9ba7'" the link works.

I'm not sure if I've missed a convention or configuration to make this work. Perhaps someone can point me in the right direction.

Apr 7, 2014 at 2:25 AM
Edited Apr 7, 2014 at 2:25 AM
Would recommend you use LINQPad to query you OData endpoint and look at what Request Log outputs for the correct OData syntax on querying against Guids.

LINQPad Request Log sample for Web Api OData query.

Apr 18, 2014 at 4:54 PM
Thank you for the reply. However, I do the know the correct syntax. What I'm unsure of is where in the sample application to make my code change.

For example, I have an edit view model (modified from your original customer VM):
define(['userDatasource', 'userModel', 'util', 'router'],
    function(userDatasource, userModel, util, router) {

        var editViewModel = new kendo.data.ObservableObject({
            loadData: function() {
                var viewModel = new kendo.data.ObservableObject({
                    saveUser: function(s) {
                    cancel: function(s) {

                    field: "UserId",
                    operator: "equals",
                    value: util.getId()

                userDatasource.fetch(function() {
                    if (userDatasource.view().length > 0) {
                        viewModel.set("User", userDatasource.at(0));
                    } else
                        viewModel.set("User", new userModel());
                return viewModel;

        return editViewModel;
For my particular Guid data type I need to cast my filter value as a Guid. My url works when formated like this: "UserId eq guid'c56858b7-95fa-45af-a24a-00e2d6bb9ba7'"

Where I'm running into trouble is in trying to understand where to my modify my filter values to make such a cast. For example, from above I tried modifying the userDataSource.Filter as such:
                    field: "UserId",
                    operator: "equals",
                    value: "guid" + util.getId()
which resulted in formatted filter statement such as this: "UserId eq 'guidc56858b7-95fa-45af-a24a-00e2d6bb9ba7'" - notice the guid cast inside the single qoute marks instead of outside them.

Could I get some help please with this specific case?

Thanks in advance.
Jul 3, 2014 at 5:53 PM
Edited Jul 3, 2014 at 5:54 PM
In LinqPad simple query the Customer as I have pictured above with a Guid and LinqPad will generate the Url it is using for you.

Pseudo sample code for LinqPad:

var myId = new Guid("5C60F693-BEF5-E011-A485-80EE7300C695");
Customer.Where(c => c.CustomerId == myId);

Click on the Request Log as pictured above and you will see the correct syntax.
Marked as answer by lelong37 on 12/19/2014 at 5:46 PM