views:

22

answers:

1

I have 2 questions :

i) How can put this code in a transaction ?

With ObjectContext in EF, I use ExecuteStoreQuery() method to start some stored procedure. I have a block of code like this :

{
    foreach(...)
    {
     objectContext.ExecuteStoreQuery( @"INSERT MyProcedure (arg1, arg2) VALUES                                 ({0}, {1});", ...);
    }
     // ...
     objectContext.ExecuteStoreQuery( @"INSERT MyProcedure2 (arg1, arg2) VALUES                                 ({0}, {1});", ...);    
 } 

ii) Is possible to commit at the same time ExecuteStoreQuery() calls with object context changes with SaveChanges() ?

My object context is changing in my code. At the end, I have to do a SaveChanges() to commit in the database. I'd like to commit in a same transaction the update of my objectContext data and all ExecuteStoreQuery. Is it possible ?