var user = await context.Customers
.Include(x => x.CustomerPreferences)
.ThenInclude(up => up.CustomerNations)
.Where(x => x.Id == userId).FirstOrDefaultAsync(cancellationToken);
CustomerNations Entity has
public Customer Customer { get; set; } = null!;
public virtual IList<CustomerNation> CustomerNations { get; set; } = new List<CustomerNation>();
I have no record in CustomerNation table. However, according to this code, there is one record in CustomerNations. When I observe it during debug, Result view shows 0 results.
var preferences= user.preferences
.ToList();
if (preferences.Any())
{
var customerNations= user.CustomerPreferences
.Select(x => x.CustomerNations);
if (customerNations.Count() != 0) //Both, Any() and Count shows there is one record. I check dropdown and Result view has 0 results.
{
foreach (var nation in customerNations)
{
context.Remove(counterParty);
}
}
}
