Print Page | Close Window

Removing DynamicEntities from cache

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=210
Printed Date: 26-Mar-2025 at 6:24am


Topic: Removing DynamicEntities from cache
Posted By: Customer
Subject: Removing DynamicEntities from cache
Date Posted: 12-Jul-2007 at 3:44pm

I would like to know how I could clear from the cache all DynamicEntity instances.

We’re using PersistanceManager.RemoveEntities(type, datarowstate).




Replies:
Posted By: IdeaBlade
Date Posted: 12-Jul-2007 at 3:45pm
 

Try this:

 

      foreach (EntityTypeInfo eti in EntityTypeInfo.GetAllDynamicTypes()) {

        if (typeof(DynamicEntity).IsAssignableFrom(eti.EntityType) && (eti.DataSourceExtension == this.mPm1.DataSourceExtension)) {

          this.mPm1.RemoveEntities(eti.EntityType, DataRowState.Unchanged);

        }

      }

 

The EntityTypeInfoGetAllDynamicTypes method is unfortunately misnamed – it will return all known entity types, and also returns everything for all known data source extensions.  (I might enter a defect report to fix this.)  Anyway, if you then filter out actual dynamic types for your data source extension, you can then do the RemoveEntities call.  Note that the dynamic entity type still exists, and its entity table is still in the PM.  Also note that removing entities with this overload, even if dynamic, causes the query cache to be cleared.  If this behavior isn’t wanted, you’d have to first retrieve the entities, and then use the RemoveEntities(list, bool) overload.




Print Page | Close Window