Reputation: 43
I have a strange problem (or I am not seeing something obvious :) )
First, I am getting data from dbcontext:
using (var dbContext = new DemoDataDBContext())
{
var data = (from m in dbContext.Customer
where m.datecreated >= DateFrom
&& m.datecreated <= DateTo
orderby m.datecreated ascending
select m).Take(PageSize).ToList();
Customers = new ObservableCollection<Customer>(data);
}
Data is displayed, everything ok. Next, I am inserting new record (different procedure):
Customer tmp = new Customer()
{
name = CurrentCustomerName,
address = CurrentCustomerAddress,
datecreated = DateTime.Now
};
dbcnt.Customer.Add(tmp);
dbcnt.SaveChanges();
Here is the problem. When using first procedure again, I am getting the same data as first time (without new inserted object).
Any ideas why am I not getting new data?
One more thing - when restarting app new data is visible.
Upvotes: 1
Views: 1921
Reputation: 5771
The data is getting inserted in your database. It could be the where conditions and page size that are limiting the data from being shown on screen.
Try removing those conditions to debug and you will be able to find the problem
Upvotes: 1