Hi,
We are using Devforce 5.1 and I've come across an issue where IQueryable<T>.Count() seems to return only the count of entities that are actually in the database and does not include the ones that have been newly created and are still in the cache.
As an example I have used Northwind and the Product table.
Facade
facade = new Facade();
DomainModel.DomainModelEntityManager mgr = new DomainModel.DomainModelEntityManager();
int count = facade.GetProducts(mgr).Count<DomainModel.Product>(); <=== This returns 77
DomainModel.Product p = DomainModel.Product.Create(mgr, 9000, "Test"); <=== We create a new product
count = facade.GetProducts(mgr).Count<DomainModel.Product>(); <=== This still returns 77
List<DomainModel.Product> l = facade.GetProducts(mgr).ToList<DomainModel.Product>(); <== We convert it to List
count = l.Count<DomainModel.Product>(); <==== Now the count has 78
The only way I have been able to get the correct count of items in my entity set is to convert the IQueryable results to a List, and then get a count.
Is this a bug? or something done by design? If so, what was the rationale behind it?
Cheers
Jacob Jozwiak