Using your example (as-is), this is the SQL I got:
SELECT TOP(1) [LPA_L1].[CustomerID] AS [CustomerId], ...
FROM [Northwind].[dbo].[Orders] [LPA_L1]
WHERE ((([LPA_L1].[OrderID] = 1)))
SELECT TOP(1) [LPA_L1].[CategoryID] AS [CategoryId], ...
FROM [Northwind].[dbo].[Products] [LPA_L1]
WHERE ((([LPA_L1].[ProductID] = 2)))
SELECT TOP(1) [LPA_L1].[CustomerID] AS [CustomerId], ...
FROM [Northwind].[dbo].[Orders] [LPA_L1]
WHERE ((([LPA_L1].[OrderID] = 10248)))
INSERT INTO [Northwind].[dbo].[Order Details]
([Discount],
[OrderID],
[ProductID],
[Quantity],
[UnitPrice])
VALUES (1,
1,
1,
1,
1)
ROLLBACK
SELECT TOP(1) [LPA_L1].[CustomerID] AS [CustomerId], ...
FROM [Northwind].[dbo].[Orders] [LPA_L1]
WHERE ((([LPA_L1].[OrderID] = 10248)))
INSERT INTO [Northwind].[dbo].[Order Details]
([Discount],
[OrderID],
[ProductID],
[Quantity],
[UnitPrice])
VALUES (2,
2,
2,
2,
2)
COMMIT
Repro code:
adapter.StartTransaction(IsolationLevel.Serializable, "Test Rollback");
LinqMetaData md = new LinqMetaData(adapter);
var product1 = md.Product.First(p => p.ProductId == 1);
var product2 = md.Product.First(p => p.ProductId == 2);
var order = md.Order.First(o => o.OrderId == 10248);
OrderDetailEntity orderDetail1 = new OrderDetailEntity()
{
Order = order,
Product = product1,
UnitPrice = 1,
Quantity = 1,
Discount = .1f
};
adapter.SaveEntity(orderDetail1);
adapter.Rollback();
adapter.StartTransaction(IsolationLevel.Serializable, "Test Commit");
order = md.Order.First(o => o.OrderId == 10248);
OrderDetailEntity orderDetail2 = new OrderDetailEntity()
{
Order = order,
Product = product2,
UnitPrice = 2,
Quantity = 2,
Discount = .2f
};
adapter.SaveEntity(orderDetail2);
adapter.Commit();
Which means that it works as expected. Please check your real scenario to see what exactly is missing. In this case, creating the order again, unlink the previous detail:
order = md.Order.First(o => o.OrderId == 10248);
In your real code, you might need to do that or unlink it manually, setting it to null, as your commented line:
orderDetail1.Order = null;
If you are getting different results in this test code, please give us more information. I tested it with LLBLGen v4.2. What is your LLBLGen version and runtime library version? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7718 )