Hi There, I have read a lot of posts regarding this message online, but I can't figure out why. I think maybe I don't understand prefetch paths completely in relation to in-memory objects. I get the following error when I change part of the query ( specifically the shopping cart.rolename )
The entity is out of sync with its data in the database. Refetch this entity before using this in-memory instance.
So - I read the data once, change the predicate expression in the subpath , and read again and I get that error. I am doing no updating whatsover anywhere ( I even ran SQL profiler to check ) .
Any ideas? Here is the code that I am using in both cases - the only difference is..
VwSkudetailsFields.RoleName == ShoppingCart.RoleName << Rolename will have changed the second time around. It errors in the categoryMod.BindData(category) which is only reading one of the values into a string.
string categoryName = Request.QueryString["cname"];
CategoryEntity category = new CategoryEntity();
category.CategoryName = categoryName;
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(CategoryFields.CategoryName == categoryName);
PrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.CategoryEntity);
prefetch.AddCategoryEntity.PrefetchPathProductCollectionViaCategoryProduct).SubPath.Add(ProductEntity.PrefetchPathVwSkudetails,0, new PredicateExpression(VwSkudetailsFields.RoleName == ShoppingCart.RoleName));
adapter.FetchEntityUsingUniqueConstraint(category,category.ConstructFilterForUCCategoryName(), prefetch);
}
categoryMod.BindData(category);