Using Dynamic Linq Select - Guid field throwing exception

dynamic-linq

Question

My Database column name is "Guid" , Since the DB is mapping to many applications and also already in production I couldn't able to change the DB field,

Error Occurs only if Field Name is "Guid"

var query2 = db2.Charities.Select("New(Name as CharityName,City as City,new Guid as Guid)");

enter image description here

1
1
3/16/2019 11:50:11 AM

Popular Answer

When using System.Linq.Dynamic.Core you should be able to use the @ character to escape predefined names.

Example code:

var queryable = new[] { new { Id = 1, Guid = "a" } }.AsQueryable();

var result = queryable.Select("new (Id, @Guid, 42 as Answer)").ToDynamicArray();

See also example unit test

1
3/20/2019 6:06:02 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow