Hi,

I'm hoping doing all right to get technical support. :)

I have a question to the System.Data.SQLite in action with the .Net 
TransactionScope.
In the SQLite documentation is written that the default behavior of a 
transaction in case of an error is
"ABORT". In documentation is also writen that "prior SQL statements within the 
same transaction are preserved and the transaction remains active".


In my case using a transaction does not show this behaves. To be little more 
clear here some example code:

                using (dataGroupDBEntities context = new 
dataGroupDBEntities(this.GetDataGroupConnection(cachedSensor.Logger.DataStorage 
as FileBasedDataStorage)))
                {
                    using (TransactionScope transaction = new 
TransactionScope())
                    {
                        foreach (SensorValuePair data in sensorData)
                        {
                            // create sensor data
                            SensorData newSensorData = new SensorData
                            {
                                TimeStamp = data.Timestamp,
                                SensorID = cachedSensor.SensorID,
                            };
                            // save to DB
                            context.AddObject("SensorData", newSensorData);
                        }
                        try
                        {
                            context.SaveChanges(SaveOptions.None);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        finally
                        {
                            transaction.Complete();
                            context.AcceptAllChanges();
                        }
                    }
                }

In this example I added 10 objects to the context and I know that object #5 
raises a PrimaryKey (or unique) Exception.
What I read from the SQLite documentation I understand that object #6 till 
object #10 will be also add to the database.
But this never happens. :( Can you help me?

Regards

Steffen Mangold
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to