Hi Markus! Thanks for your feedback, that helped alot. Currently I'm working based on a legacy database so I can't change the primary key types of my classes. Although I think GUIDs are ok and easy to implement, our database administrators do not like them and prefer integer values as PKs instead. I never used HiLo before, but I'll give it a try to see if I can use it for future applications.
Best Regards Markus On 17 Okt., 14:43, Markus Zywitza <[email protected]> wrote: > Hi Markus > the problem is the Identity PK. See > here:http://www.castleproject.org/ActiveRecord/documentation/trunk/usersgu... > > Try using a GuidComb or HiLo and you'll see no database calls at all with > FlushAction.Never > > -Markus > > 2009/10/16 Markus <[email protected]> > > > > > 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 -~----------~----~----~----~------~----~------~--~---
