Good day,
In my sample scenario, I'm trying to fetching all users from my database and put then on my dto where it has lists of ordering by alphabet letters given the following: A-L, M-Z
Here's my sample code with common OrderBy
by the user name:
var users = await users.Users().ToListAsync();
return users.Select(u=>new CategorizedByLetterUserDto{
...
}).OrderBy(u=>u.Name);
So my sample CategorizedByLetterUserDto
looks like this.
public class CategorizedByLetterUserDto {
public IEnumerable<AtoL> AtoL {get;set}
public IEnumerable<MtoZ> MtoZ {get;set;}
...
}
public class AtoL{
public int Id {get;set;}
public string Name {get;set;}
}
public class MtoZ{
public int Id {get;set;}
public string Name {get;set;}
}
so on and so forth...
So the result will be (array)
{
categorizedByLetterUserDto: {
atoL: [
{
...
}
],
mtoZ: [
{
...
}
]
}
}