NHibernate cascade and generated guid ids - why are they not generated for the children on save?

Posted by asgerhallas on Stack Overflow See other posts from Stack Overflow or by asgerhallas
Published on 2010-02-09T15:34:32Z Indexed on 2010/03/17 12:41 UTC
Read the original article Hit count: 202

I do the following:

    var @case = new Case
    {
        Name = "test"
    };

    // User is persistent and loaded in the same session
    User.AddCase(@case); // sets @case.User = User too
    Session.Update(User);

    response.CaseId = @case.Id;

The cascade on User.Cases is set to All. But @case.Id is not set until the transaction is committed. Is that expected behavior? I would very much like to get the Id before committing. Can it be done?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about .NET