hydrologics/Oasis.Base — Issue #62: Metadata objects not available in ObjectSet until after .SaveChanges()
Author: danrichardson
Created: 2011-12-30 07:36:14+00:00
State: open

This is a weird one, but read this: http://stackoverflow.com/questions/5760743/ef4-objectset-addobject-not-working

I was looking at objects to see if they had metadata created, and if not, create it. I was doing this by querying the Metadata objectset for an ElementGUID - the only problem is that it was always returning null!

BUT! If I executed a SaveChanges(), the metadata was in the DB. Oh. Kay.

Apparently, this is either a bug of by design. If I read this correctly, you can add or delete objects from a Parent object, and they will be available to tinker with (Run.), but metadata won't be available until after we save.

Here's what I'm thinking about exploring: We can create a list of metadata that we add, and query that list.... upon SaveChanges, null out the list.

I have an initial exploration that I put into ContextAdapter and MetadataManager that appears to be working well. Not sure what the speed penalty will be for this, but since it's only during Save operations, we can afford to take a bit of a hit.