Print Page | Close Window

Debugging the EntityManager Cache

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2421
Printed Date: 24-Jan-2026 at 2:42am


Topic: Debugging the EntityManager Cache
Posted By: c63205
Subject: Debugging the EntityManager Cache
Date Posted: 05-Jan-2011 at 4:10pm
I'm getting a FK constraint error on saving my entitymanager's data to the DB.  Is there a way to dynamically just purge/serialize the entities that are in the Cache to xml or some readable format.  I tried using the savecachestate() but its not readable (as expected).  This would purely be for development and debugging.

Perhaps someone has a tool or utility for this?

Thanks,



Replies:
Posted By: DenisK
Date Posted: 06-Jan-2011 at 1:09pm
Hi c63205;

As of 6.0.6, the SaveCacheState method now has an option to save in binary or text format.


Posted By: c63205
Date Posted: 06-Jan-2011 at 2:27pm
OK, perhaps I wasn't using the correct encoding when reading from the stream.  I had entered 'false' for the binary parameter but the data wasn't readable.  Is the text structured at all (xml, etc?)  

It might be cool for 'someone' to create a little utility to traverse the EntityManagers entity graph and visualize the contents.  Perhaps a visual studio debugging visualizer widget.  Obviously not a big priority, but would be cool and perhaps useful. 


Posted By: DenisK
Date Posted: 06-Jan-2011 at 2:53pm
c63205;

When flag sets to true, the EntityCacheState is written into a binary xml format.

When flag sets to false, the EntityCacheState is written into a text xml format. 

I have tested the following code and made sure that the output was correct for each option.

var mgr = new NorthwindIBEntityManager();
var customers = mgr.Customers.FirstOrNullEntity();
mgr.CacheStateManager.SaveCacheState(@"C:\temp\EntityCacheStateXml.xml", false);
mgr.CacheStateManager.SaveCacheState(@"C:\temp\EntityCacheStateBin.bin", true);



Print Page | Close Window