GridForeignColumn incorrectly converts string to Guid

Hi,

I'm having a problem in using a GridForeignColumn, where the Field and ForeignKeyField both are strings. However, since the values look like a guid, the URI is formatted as a Guid and fails. All relevant models and database values are of the type String.

This fails:
https://localhost:7230/odata/Customer/101?$filter=(No eq ac589e91-077e-49f1-a5b0-0e1767b49fe7)  

and causes the following error.

"The query specified in the URI is not valid. A binary operator with incompatible types was detected. Found operand types 'Edm.String' and 'Edm.Guid' for operator kind 'Equal'."


This works as intended:

https://localhost:7230/odata/Customer/101?$filter=(No eq 'ac589e91-077e-49f1-a5b0-0e1767b49fe7')



1 Reply

PS Prathap Senthil Syncfusion Team January 8, 2025 11:57 AM UTC

Hi Toke Nygaard Olsen ,

Based on the reported issue, we would like to clarify that when filtering values in the grid, it is not possible to differentiate between a normal string and a GUID value. When the value matches a GUID type, it will be converted to a GUID. We have provided support for GUID column so ,we suggest using the Guid property type to resolve the issue. Kindly refer to the code snippet and simple sample below for your reference


Ex.
public class OrderStatus

{

     [Key]

     [DatabaseGenerated(DatabaseGeneratedOption.Identity)]

     public long OrderStatusId { get; set; }

     public Guid? Status { get; set; }

     public bool? IsCompleted { get; set; }

 

 

}


Regards,
Prathap Senthil


Attachment: OdataV4WithFK_b5e59d4e.zip

Loader.
Up arrow icon