Moving Dropdown DataFieldCategory to bottom of list

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Moving Dropdown DataFieldCategory to bottom of list



I have a list of "Care Items" that possess a soft delete bool, an ID, a name, and a Category.



Currently, I am querying for all! IsDeleted and it populates just fine under with each item grouped under their appropriate categories.



I am now changing it so that items that are IsDeleted populate in a "Disabled Care Item" Category. That works fine, but "Disabled Care Item" is showing up where you would expect it to in the middle of a list with 10-20 categories each with at least a few items in each. So disabled gets lost. I would love to be able to move the disabled category and items to the bottom of the list, but each time I try I am getting implicit casting errors between my lists or errors against IQueryable since I'm LINQing for these results.



I know there is somebody clever out there who has a solution for this complete noob.


var query = CareItemFactory.Instance.GetByCareProgram(facilityId, careProgramId);

if (!includeDisabled)
{
query = query.Where(x => !x.IsDisabled && !x.CareItemCategory.IsDisabled);
}

return query.Select(i => new CareItemView
{
ID = i.ID,
Category = i.IsDisabled == true ? $"Disabled Care Items" : i.CareItemCategory.Name,
Name = i.Name
}).ToList();




1 Answer
1



How about this?


var query = CareItemFactory.Instance.GetByCareProgram(facilityId, careProgramId);

var resultQuery = query.Where(x => !x.IsDisabled && !x.CareItemCategory.IsDisabled)
.Select(i => new CareItemView
{
ID = i.ID,
Category = i.CareItemCategory.Name,
Name = i.Name
});

if (includeDisabled)
{
var resultQuery = resultQuery.Union(query.Where(x => x.IsDisabled || x.CareItemCategory.IsDisabled)
.Select(i => new CareItemView
{
ID = i.ID,
Category = $"Disabled Care Items",
Name = i.Name
}));
}

return resultQuery.ToList();






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP