Print Page | Close Window

Emitting DML scripts ...

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2509
Printed Date: 13-Sep-2025 at 11:54pm


Topic: Emitting DML scripts ...
Posted By: klmcwhirter
Subject: Emitting DML scripts ...
Date Posted: 14-Feb-2011 at 5:51pm
After I have manipulated the objects for a given Entity I now would like to emit DML (delete, update, insert statements) for that Entity.
 
I have looked all the way into the PersistenceServer, but am not finding the elegant hook I am looking for.
 
PersistenceServer has the AdapterProviderMap which may help if I could add my own IAdapterProvider at the right moment in time, but cannot get to the underlying instance via PersistenceServer. And even that seems like it would be more work than would be practical for one single Entity. Next thought ...
 
It seems like overriding the TransactionManagerHelper.SaveTable(...) method would head me down the path I am looking for. This would mean creating my own ITransactionManager (that would use my helper imp) which leads to creating my own PersistenceServer to use my ITransactionManager implementation. PersistenceManager has a ctor that takes a PersistenceServer. But, sheesh ...
 
 
See my point? I think I am over complicating this.
 
 
Is there a simple way to have pm.SaveChanges() emit a SQL DML script and *think* it saved successfully if the script was saved - and save nothing to the table it originally read from?
 
 
If need be I can just hard code the DML in the Entity - but thought there must be an elegant solution to allow DevForce to call the delete, update, inserts in the correct order, etc.
 
Thanks in advance.



Replies:
Posted By: kimj
Date Posted: 14-Feb-2011 at 6:21pm

A custom IAdapterProvider is the supported way of doing this.   DevForce will find your implementation if it's in the probe assembles, and  based on the return value of the SupportedEntityTypes property use your provider for only the entity type(s) wanted.  DevForce will take care of adding it to the map, so yo don't need to poke it or the PersistenceServer or muck with other DevForce internals.

There's a sample IAdapterProvider in the learning unit "Insert Delete Update with Stored Procs".


Posted By: klmcwhirter
Date Posted: 15-Feb-2011 at 8:01am
Yeah, I saw that tutorial. Still too much work and not enough control. I do not want to probe to include it. There are other parts of the app that need to use the default IAdapterProvider.
 
So that would not work.
 
Thanks anyway.
 



Print Page | Close Window