I'm using LLBLGen 2.5, SQL Server 2005 (9.0.1399), VS2005, and .NET 2.0.
While attempting to save a newly created entity, the code throws an ORMConcurrencyException.
After reading this thread: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=10121 I looked into the connection properties and made sure that NOCOUNT is set to OFF.
The code in question is:
UserRoleEntity _ure = new UserRoleEntity();
_ure.IsNew = false;
_ure.User = _user;
_ure.Role = _role;
_ure.Organization = null;
if (!_adapter.FetchEntityUsingUniqueConstraint(_ure, _ure.ConstructFilterForUCUserIdRoleIdOrganizationId()))
{
_ure = new UserRoleEntity();
_ure.UserRoleId = Guid.NewGuid();
_ure.User = _user;
_ure.Role = _role;
_ure.Organization = null;
try
{
_adapter.SaveEntity(_ure);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
I ran SQL Profiler against the SaveEntity call, and two statements are run:
exec sp_executesql N'INSERT INTO [hisd_new].[dbo].[UserRole] ([UserRoleID], [UserID], [RoleID]) VALUES (@UserRoleId, @UserId, @RoleId)',
N'@UserRoleId uniqueidentifier,@UserId uniqueidentifier,@RoleId uniqueidentifier',
@UserRoleId='1E50E42F-E66B-4D8E-B0BA-A4AB19E110C9',
@UserId='4AA605F8-B0DE-49EA-AE2D-5443A980BAF9',
@RoleId='601D108C-E8E6-48D3-A10F-C4F53CC6D39D'
exec sp_executesql N'UPDATE [hisd_new].[dbo].[UserRole] SET [UserID]=@UserId,[RoleID]=@RoleId WHERE ( [hisd_new].[dbo].[UserRole].[UserRoleID] IS NULL)',
N'@UserId uniqueidentifier,@RoleId uniqueidentifier',
@UserId='4AA605F8-B0DE-49EA-AE2D-5443A980BAF9',
@RoleId='601D108C-E8E6-48D3-A10F-C4F53CC6D39D'
Thanks in advance for any help on this, I've stepped through this a number of times, and I'm at a bit of a loss.
Jeremiah