We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

AspNet Core ODataV4Adapter entity with string key

Thread ID:





144835 May 24,2019 04:45 PM UTC May 29,2019 10:43 AM UTC ASP.NET Core - EJ 2 1
Tags: DataGrid
Scott Lambert
Asked On May 24, 2019 04:45 PM UTC

I have been working with the Aspnet Core 2.2 EJ2 Grid the grid is using the ODataV4Adapter, my entity has a primary key that is a string version of a guid. I am trying to bind it toe the following function signature:

public IActionResult Get([FromODataUri] string key) { }

My problem is that the adapter sends any request that requires the key as:

Aspnet Core 2.2 OData will not bind this value to the key parameter,

It will bind, if the key is enclosed in single quotes: 

Aspnet Core OData requires the single quote marks to bind. I have tried many things on the backend such as custom binders and custom OdataRoutingConventions, none work.

It is not clear to me how to force the ODataV4Adapter to enclose the key in single quotes, for post, patch and put requests. Nor can I see how I can trap the request before it is sent and wrap the key in quotes on the client side. Nor can I find an event that fires that I would be able to leverage to do this.



Pavithra Subramaniyam [Syncfusion]
Replied On May 29, 2019 10:43 AM UTC

Hi Scott, 
Sorry for inconvenience caused, 
We have validated your query and we suspect that you have expecting single quote query(guid value in single quotes which is primary key field) property with POST, PUT, Patch actions in ODataV4Adaptor. But, for OdataV4 we need to send the request without quotes and which is working fine at our end. We suggest you to refer the below code example and reference for more information. 
<ejs-grid id="Grid" allowPaging="true" allowSorting="true" allowFiltering="true" toolbar="@(new List<string>() { "Add","Delete","Update","Cancel" })">         
        <e-grid-editSettings allowAdding="true" allowEditing="true" allowDeleting="true" mode="Normal"></e-grid-editSettings>       
        <e-data-manager url="/odata/Books" adaptor="ODataV4Adaptor"></e-data-manager> 
            <e-grid-column field="guid" headerText="GuID" isPrimaryKey="true" width="150"></e-grid-column> 
            .   .   .   . 
// GET api/values 
        public IQueryable<Book> Get() 
            return _db.Books; 
        // POST api/values 
        public IActionResult Post([FromBody]Book book) 
            return Created(book); 
        // PUT api/values/"5" 
        public async Task<Book> Put(string id, [FromBody] Book book) 
            var entity = await _db.Books.FindAsync(book.guid); 
            await _db.SaveChangesAsync(); 
            return book; 
        // DELETE api/values/5 
        public async Task<int> Delete(int key) 
            var od = await _db.Books.FindAsync(key); 
            await _db.SaveChangesAsync(); 
            return key; 
public class Book 
        // Please ensure the Guid field type declaration 
        public Guid guid { get; set; } 
        public int Id { get; set; } 
        public string ISBN { get; set; } 
        public string Title { get; set; } 
        public string Author { get; set; } 
        public decimal Price { get; set; } 
Pavithra S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon