Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0125· OpenAIAi2 WildChat-4.8M (AI2)

Convert to c# ef core 6 - "SELECT ObjectId,STRING_AGG(CategoryName,';') FROM ( SELECT…

  1. User

    Convert to c# ef core 6 - "SELECT ObjectId,STRING_AGG(CategoryName,';') FROM ( SELECT e.ObjectId, e.Name as ElementName, c.Name as CategoryName FROM [I-DS-P].[dbo].[ObjectInCategory] oic join Element e on e.ObjectId = oic.ObjectInCategoryId join Category c on c.ObjectId = oic.CategoryId ) as vv group by ObjectId"

  2. Assistant
    var result = context.ObjectInCategories
        .Include(oic => oic.Element)
        .Include(oic => oic.Category)
        .Select(oic => new { oic.Element.ObjectId, oic.Category.Name })
        .GroupBy(x => x.ObjectId)
        .Select(g => new { ObjectId = g.Key, CategoryNames = string.Join(";", g.Select(x => x.Name)) })
        .ToList();