Good afternoon,
I have previously posted a problem about devforce queries bypassing the cache. That problem was solved using a more recent version of Devforce. Today I have installed what I believe is the latest versaion of Devforce but I found a new case of the cache being bypassed.
I'm using Devforce 2010, version 6.1.3.3 on SQL Server 2008 R2.
Say I want to group orders by customerId and employeeId and take all orders where the count of the grouping is say above 2.
The query would look like this:
var orderList = manager.GetQuery<Order>() .GroupBy(it => new { it.CustomerID, it.EmployeeID }) .Where(g => (g.Count() > 2)) .SelectMany(g => g, (g, order) => order);
|
This query gives me all orders meeting the criteria but is always executed against the database server.
So if I create a new employee, a new customer and create 3 new orders for that new customer placed by my new employee, now the above query does not returns my new orders.
Though, employee count is now one more than at the start of the program, so is customer and order count is 3 more than at the start but still my groupby query does not see the new orders.
If I then apply changes to the database using the
command, the group by query shows my new orders.
I feel this is not right, I wish all my queries to hit the cache first then the database. How can I do so when using grouping queries?
Thanks a lot for your support
Frederic
Sample code:
NorthwindIB manager = new NorthwindIB( dataSourceExtension: String.Empty,
entityServiceOption: IbEm.EntityServiceOption.UseLocalService,
compositionContextName: String.Empty);
var employeeQuery = manager.GetQuery<Employee>(); var customerQuery = manager.GetQuery<Customer>(); var orderQuery = manager.GetQuery<Order>();
var orderList = manager.GetQuery<Order>() .GroupBy(it => new { it.CustomerID, it.EmployeeID }) .Where(g => (g.Count() > 2)) .SelectMany(g => g, (g, order) => order);
Int32 employeCountBefore = employeeQuery.ToList().Count; // 9 Int32 customerCountBefore = customerQuery.ToList().Count; // 93 Int32 orderCountBefore = orderQuery.ToList().Count; // 830 Int32 orderListCountBefore = orderList.ToList().Count; // First time count is 324 Employee newEmployee = AddEmployee(manager); Customer newCustomer = AddCustomer(manager); AddThreeOrders(manager, newEmployee, newCustomer);
Int32 employeCountAfter = employeeQuery.ToList().Count; // 10 Int32 customerCountAfter = customerQuery.ToList().Count; // 94 Int32 orderCountAfter = orderQuery.ToList().Count; // 833 Int32 orderListCountBeforeSave = orderList.ToList().Count; // Still 324 !!!
manager.SaveChanges();
Int32 orderListCountAfter = orderList.ToList().Count; // Now 327 !!!
|