Hi all!
I experience a problem when using SessionScopes and the latest AR 2.0.
Using MS SQL Server Profiler I found an issue when using a
SessionScope with FlushAction.Never. To illustrate the problem I
created a simple Customer class that just a Name property (besides the
primary key).
Using these lines of code:
using (new SessionScope())
{
var c = new Customer { Name = "ALFKI" };
c.Save();
c = new Customer { Name = "DUMMY" };
c.Save();
}
in order to create two customers in the database, the SQL Server
Profiler shows me these SQL statements:
Audit Login
BEGIN TRANSACTION
exec sp_executesql N'INSERT INTO Customers (Name) VALUES (@p0); select
SCOPE_IDENTITY()',N'@p0 varchar(5)',@p0=N'ALFKI'
exec sp_executesql N'INSERT INTO Customers (Name) VALUES (@p0); select
SCOPE_IDENTITY()',N'@p0 nvarchar(5)',@p0=N'DUMMY'
COMMIT TRANSACTION
Audit Logout
Now using the same code from above but this time passing
FlushAction.Never to the SessionScope constructor leads to the
following SQL:
exec sp_reset_connection
Audit Login
exec sp_executesql N'INSERT INTO Customers (Name) VALUES (@p0); select
SCOPE_IDENTITY()',N'@p0 nvarchar(5)',@p0=N'ALFKI'
Audit Logout
exec sp_reset_connection
Audit Login
exec sp_executesql N'INSERT INTO Customers (Name) VALUES (@p0); select
SCOPE_IDENTITY()',N'@p0 nvarchar(5)',@p0=N'DUMMY'
Audit Logout
As you can see, two logins were executed for each INSERT - which I
think is not a desirable behaviour. Is there a fix for that issue?
Best Regards
Markus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---