I'm sorry for the question form, as I don't know what is the name of this concept. If there are any suggestions I'll change it.
I View Model VMHome and I need to make one of its props to be like this
List<string,string,int>
Because I have Iqueryable result and I think that structure would be corresponding. Anyway here is the needed cast message
It is basically Iqueryable like this when using var
after my attempt, it looks like this when using view model
and here is my attempt to make "immutable struct"
public class VMHome
{
public List<categoryListPostCount> CategoryListPostCount { get; set; }
// immutable struct
public struct categoryListPostCount
{
public categoryListPostCount(string categoryName, string categoryID, int count)
{
CategoryName = categoryName;
CategoryID = categoryID;
Count = count;
}
public string CategoryName { get; set; }
public string CategoryID { get; set; }
public int Count { get; set; }
}
}
And here is the faulty usage
// ... inject vmHome.. and then
vmHome.CategoryListPostCount =
(from cat in context.postCategories
join con in context.postContents
on cat.Id equals con.postCatId
group new { cat, con } by new { con.postCatId, cat.categoryName } into g
select new
{
//g.Key,
CategoryName = g.Key.categoryName.ToString(),
CategoryID = g.Key.postCatId.ToString(),
Count = g.Count()
}).ToList();


new { ... }.recordto declare your type more succinctly like so:public sealed record categoryListPostCount(string CategoryName, string CategoryID, int Count);