I dynamically build select with System.Linq.Dynamic.Core. I want to add another column (subquery). Is this possible?
I need to get same results as this query:
var test = this.DbContext.Countries.Select(t => new
{
t.Id,
t.ISOCode,
lookup = t.Translates.Where(t2 => t2.LangISOCode=="ENG").Select(t2 => t2.Title).FirstOrDefault()
}).ToArray();
I get this far:
this.DbContext.Countries.Select("new(Id,ISOCode)").ToDynamicArrayAsync()
but not sure how to add additional subquery column.
Solution is:
await this.DbContext.Countries.Select("new(Id,ISOCode,Translates.Where(LangISOCode=\"SLV\").Select(Title).FirstOrDefault() as translates)").ToDynamicArrayAsync();
I found solution by combing code from source tests (select, where, firstordefault).