I'm not sure if it's a correct behavior or something done wrong on my side:
I've got a very simple parent-child relationship
public class SubmittedBatch
{
public virtual Guid Id { get; set; }
public virtual IList<SubmittedBatchParameter> Parameters { get; private set; }
}
public class SubmittedBatchParameter
{
public virtual string Value { get; set; }
}
And with FluentNH it is configured like:
mapping.HasMany<SubmittedBatchParameter>(sb => sb.Parameters).Cascade.All();
I do something easy like adding a new element to the Parameters
collection and then call SaveOrUpdate
on the parent element.
Looking at the trace of the SQL Statements I get an insert:
INSERT INTO [SubmittedBatchParameter]
(Value)
VALUES ('Disabled' /* @p0 */)
select SCOPE_IDENTITY()
and then an update:
UPDATE [SubmittedBatchParameter]
SET SubmittedBatch_id = '209971b7-c311-46bd-b989-9cf80113654c' /* @p0_0 */
WHERE Id = 39 /* @p1_0 */
Why isn't NH just doing the Insert with also the Guid specified? Is this correct, or am I doing something wrong?
Thank you Simone