I just upgraded to 6.1.3.1 and ran into a small problem. Our app caches a lot of data to Isolated Storage and we've broken up the cache saves so we write to a separate file for each Entity Group. Previously, we could do code like this without a problem:
//Find a random entity group that has at least one entity in it (in our real // app, this logic is different but this is an easy way to reproduce the problem). var aNonEmptyGroup = _entityManager.GetEntityGroups().First(g => g.Count() > 0);
using (var dummyStream = new MemoryStream()) { //Save the entities in the given group out to the stream _entityManager.CacheStateManager.SaveCacheState(aNonEmptyGroup, dummyStream); } |
However under 6.1.3.1, this code throws an ArgumentException with a message of "already an EntityAspect". It seems some logic is trying to wrap an Entity Aspect in another Entity Aspect and it gets confused. I found an easy workaround but I'm not entirely sure it's the best way. The new code does this:
//Go through the EntityAspects in the group and grab the corresponding Entity//Is this the correct way to do it? Will the .Entity property always have a value? var entities = aNonEmptyGroup.Select(entityAspect => entityAspect.Entity);
//Save the entities in the given group out to the stream _entityManager.CacheStateManager.SaveCacheState(entities, dummyStream); |
My question is whether the code above is the best approach. Also, I guess this is a breaking change that could be documented? Unless it's actually a bug and I should be able to use my original code in 6.1.3.1?
Thanks!
-Stephen