In general, the outcome you observe is expected; the database does not notify the application (and Data Access in particular) about the result from the committed transactions. If you need to obtain the most fresh data, you need to execute a new query after the call to the SaveChanges() method. For this purpose, you could modify your code following the pattern shown below:
DataAccessModel.Category category = dbContext.Categories.First(c => c.CategoryID == 1);
prodsCount = category.Products.ToList().Count;
DataAccessModel.Product product =
Category = category
prodsCount = category.Products.Count;
I would also recommend you the following sections from our documentation:
- CRUD Operations
regarding the retrieval of data from the database
- Manage Navigation Properties
regarding the handling of related database objects
I hope this helps. Let us know if you need further information.
Check out the latest announcement
about Telerik Data Access vNext as a powerful framework
able to solve core development problems.