简体   繁体   中英

Unable to convert value of type System.String to OData type [Edm.Guid Nullable=True]

My User class is like below when I try to update record using below query it gives me exception.

public class User
{
    public User();

    public Guid Id { get; set; }
    public virtual Language Language { get; set; }
    public Guid? LanguageId { get; set; }
    public virtual City City { get; set; }
    public Guid? CityId { get; set; }
}

code

            Guid cityId = new Guid("4B1FCCA6-3E43-44BA-8516-BC693F02E9B5");

            await myClient.For<User>()
            .Filter(t => t.CityId == cityId)
            .Set(new { LanguageId = languageId  })
            .UpdateEntryAsync();

after executing above update statement i'm getting exception Unable to convert value of type System.String to OData type [Edm.Guid Nullable=True] myClient is Simple Odata client

Apparently LanguageId = languageId is giving you this error because Guid type is different. One is .net inbuild and one I think you are getting from your service call. Also, I think languageId here is string which is causing the problem

As defined here http://www.odata.org/documentation/odata-version-2-0/overview/

Edm.Guid : Represents a 16-byte (128-bit) unique identifier value. 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM