This project is read-only.

How do I - refresh my subdomain?

Jun 29, 2011 at 11:48 PM

Lets say I have a subdomain I am working with and part of it changes (the database has been changed, and I know it).  How do I refresh the appropriate collection in my subdomain without tripping any Dirty flags?





Jun 30, 2011 at 5:01 AM

I am sorry but I do not understand the question? If the database has changed you need to run the installer project against it synchronize the database with your new model. If you are saying you have changed your database at run-time then I do not know what to tell you. Change the model. Re-generate. Run the installer project against your database and your application will match your database.

Jun 30, 2011 at 6:00 AM

The database schema is not changing, sorry for being unclear.

I only mean that another form has modified a collection  and persisted it to the data store.

From there another form (now aware that the data in the store has changed) needs to update the data in the appropriate collection in its subdomain.

The second forms subdomain should not be dirtied by this "re-query" of the data store.


I hope I have made my desired functionality clearer.

Is such a thing possible?




Jun 30, 2011 at 6:44 AM

My first thought was to merge my existing sub domain with "samplecollection.RunSelect().ParentCollection.SubDomain"  I am concerned about what will happen if there are differences in rows with the same primary-key, which record will then exist in my sub domain, and will my sub domain be automtically marked dirty?




Jun 30, 2011 at 5:12 PM

It looks like this will work

_data.ParentCollection.SubDomain.Merge(assessment.ParentCollection.SubDomain, False, MissingSchemaAction.AddWithKey)

There is however a problem with it changing the  "ModifiedBy" audit field if this action is performed when the data I just re-queried (assessment) has no changes from what is already in the subdomain.

This may relate to BUG 6844 that I already submitted.


Jul 1, 2011 at 11:25 PM

I honestly do not have any good suggestions for this situation. You really should pass the object up your Forms chain and only work on one object. However if you insist on loading new objects in each form then I cannot suggest much. I would load some object in Form1 and if you need to display another dialog, Form2, I would pass the previously loaded object to it. I do not know why you would load a new object or group object objects. 

Alternatively you could pass the subdomain to the new forms. If you do this then you could use that container to load some other collection, which is what I think you are really doing. Use the same subdomain to load one or more collections and they all exist in the same container. When you call the Persist method on the subdomain (or any collection) all collections will be persisted in the same database transaction.

You are merging two collections into the same subdomain. I suggest you simply load both collection in the same subdomain and never load more than one. This way you are guaranteed to have one copy of everything.

You could load a blank collection like this and get a reference to it.

var collection2 = otherCollection.SubDomain.GetCollection<Acme.TestModel.Business.Objects.AncestorCollection>();
var newItem = collection2.NewItem(); //Add new object to the newly loaded collection

Or you could load a new collection from the database with the predefined select commands or your own custom ones of course.

otherCollection.SubDomain.AddSelectCommand(new Acme.TestModel.Business.SelectCommands.AncestorSelectAll());
otherCollection.SubDomain.RunSelectCommands(); //Load from database
var collection2 = parentCollection.SubDomain.GetCollection<Acme.TestModel.Business.Objects.AncestorCollection>();

Jul 4, 2011 at 8:29 PM

I wish I could just run

MyObject.ParentCollection.SubDomain.GetCollection(Of SubItemsCollection).RefreshFromDatabase()

Anybody have any ideas what this function would look like.  I am going to see how easy this would be to accomplish in the objectcollection's partial class.

If that proves very tricky, then I will attempt to retrofit an existing winform into allowing me to pass the subdomain around.





Sep 2, 2011 at 5:07 PM

Here's a question on the same lines that maybe someone can provide in-sight.

Is there away to remove a collection from a subdomain so when a relationship is 're-walked' the collection will be re-added with updated information?

Thanks in advance,


Sep 8, 2011 at 1:18 AM

You cannot remove a collection once loaded. The subdomain is really a small in-memory database and all sorts of relations and constraints are added and managed when a new table is added. It is difficult to decouple the data once loaded.