In MDriven I have a persistent class that I need to create a transient instance of.
Is this possible?
I do know that a workaround would be to create as usual and then discard it.
Clarification 2018-02-02 17:04 UTC+1:
I would need to do this without adding anything to the model, compile time.
Yes you are correct - it is not possible to change a class to become transient in runtime.
You can however subclass it... And make the subclass transient... I have had that exact need myself and solved it that way.
Example: The MonthDemandSupplyCorrection is persistent - but the MDSC_Placeholder is not
Update: Since the requirement was clarified to be "not known in design time" - a better answer is to create an ordinary instance and avoid saving it. This can be ensured with the undo-service and memory transactions like this:
EcoSpace.Undo.StartTransaction();
try
{
//Any changes you need
}
finally
{
EcoSpace.Undo.RollbackTransaction();
}