simsenVejle
Well-known member
- Joined
- Feb 14, 2021
- Messages
- 46
- Programming Experience
- Beginner
Hi,
I have problems to find the correct syntax to get a single result of a single row.
I get the row (categories) and I can see in this row there is a CategoryIsObsolete field (it is that value I want)
But when making af FirstOrDefault query the Category result is null - and I do not know why.
Maybe I'm doing to much - but I have first to get the row - and then I want the value for a entry in that row.
Best regards
Simsen
I have problems to find the correct syntax to get a single result of a single row.
I get the row (categories) and I can see in this row there is a CategoryIsObsolete field (it is that value I want)
But when making af FirstOrDefault query the Category result is null - and I do not know why.
C#:
DalCategory dalCategory = new DalCategory();
var categories = dalCategory.GetCategories();
//This one gives me one row
categories = categories.Where(x => x.CategoryId == SelectedCategory.CategoryId).ToList();
//This one give me a null result but there is a CategoryIsObsolete field in the categories??????
Category result = categories.FirstOrDefault(s => s.CategoryIsObsolete);
bool oldIsObsolete = result.CategoryIsObsolete;
if (oldIsObsolete != SelectedCategory.CategoryIsObsolete)
{
//Inaktiv
if (oldIsObsolete)
{
Categories_GetInactive.Remove(SelectedCategory);
Categories_GetActive.Add(SelectedCategory);
}
//Aktiv
else
{
Categories_GetActive.Remove(SelectedCategory);
Categories_GetInactive.Add(SelectedCategory);
}
}
Maybe I'm doing to much - but I have first to get the row - and then I want the value for a entry in that row.
Best regards
Simsen