Print Page | Close Window

Add Another constructor in the Factory class of Cocktail.Contrib

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3412
Printed Date: 13-Nov-2019 at 3:35am


Topic: Add Another constructor in the Factory class of Cocktail.Contrib
Posted By: Walid
Subject: Add Another constructor in the Factory class of Cocktail.Contrib
Date Posted: 27-Apr-2012 at 12:37am
Hi,

Actually the Factory class has only one constructor taking an EntityManagerProvider.

That makes it impossible to use the factories in the SampleDataProviders since there we only have an EntityManager. Could it be possible to add another constructor taking an EntityManager ? 
This constructor could be accessible only when the #FAKE conditional variable is set to avoid unauthorize use in the "real" application.



Replies:
Posted By: mgood
Date Posted: 27-Apr-2012 at 12:28pm
Using the Factory in a SampleDataProvider makes no sense. The factory creates "new" entities where as a SampleDataProvider fakes existing entities. You see the difference in how they get added to the EntityManager. The factory calls AddEntity where as in a SampleDataProvider you use AttachEntity. The difference is if you use AddEntity, the entity will be in the added state ready to be inserted into the database. AttachEntity on the other hand sets the entity state to unchanged. This is important, because sample data is supposed to fake a real database where the entities have already been inserted are are therefore in unchanged state.


Posted By: mgood
Date Posted: 27-Apr-2012 at 12:36pm
Oh and the Factory in CocktailContrib follows the asynchronous pattern, where as setting up the sample data is all synchronous.


Posted By: Walid
Date Posted: 27-Apr-2012 at 12:41pm
you are right, I totally forgot about the AddEntity/AttachEntity issue. I focused in the different task I do in the factory to create/initialize the entities and wanted to be sure the entities created in the SampleDataProvider followed the same rules as in the factory. Often when we modify the Factory we don't always remember to modify the SampleDataProvider too.

-------------



Print Page | Close Window