i'm well-aware of how to make my entity graph's object references completely
solvent.
my question is whether or not it's always required.
can i have my domain mapped as i have it above (with cascade, etc)
... so that I can do: #1
// this simulates the use-case where the user is creating a new ticket with
x notes before saving
var ticket = new Ticket();
ticket.Notes.Add(new Note() { Ticket = ticket, TicketID = ticket.TicketID
}; // ad nauseam
Session.Save(ticket);
... but also so that I can do: #2
// this simulates a use-case where the user is only adding a new ticket.
var newNote = new Note() { TicketID = 1234 } // basically, everything that
the database row needs to be inserted.
// when I do the following .. i get either a cannot insert null error
(TicketID is not null in db) or FK not valid
// NHib would either try to insert null, or 0 (int default?), presumably
because the Ticket instance was null?
Session.Save(newNote);
.. and also ... #3
// this simulates a user editing a ticket that has notes, but does not make
a change to the notes before saving
var ticket = this.TicketInstanceUserEditedAndSentToServer;
// the ticket comes back alone, meaning no Note instances are in its Notes
collection.
// which means when I do the following, NHib tries to delete the
children/null the FK in the table
Session.Update(ticket);
Is that a more clear description of how this is all happening, and why I'm
asking what I'm asking?
Can you see why it seems like a lot of overhead to re-populate the full
entity-graph in cases 2 & 3?
------------------------------------------------
> LOL. you don't get OSS do you :) not to mention the talent/value of the
people assisting you.
sure I do. money is money. free is free. somewhere in the middle are
reasonable grounds for tips, if you'd rather see it that way. as for
talent/value -- in this specific example, regardless of how super-awesome
someone thought they were in helping me, i'd still be the customer. I was
told to go away, and yet I'm still offering cash to those who help. I don't
think it's very polite on behalf of the rest of the community to say they
don't want it. ;-)
and if the community doesn't want it, I won't have a problem leaving it in
my wallet ;-) but then i won't be surprised when i finally look that gift
horse in the mouth, either.
you were in the running, but then you deferred to prior unhelpful remarks of
others so i felt less compelled.
pffsh, and you don't even want it ;-)
------
Joe Brockhaus
[email protected]
------------
On Wed, Feb 9, 2011 at 11:39 AM, Jason Meckley <[email protected]>wrote:
> when you associate a parent to a child the association goes both ways. I
> like to encapsulate my collections, so the only way to add to add a child is
> by the parent. it looks like this
>
> class Parent
> {
> private ICollectio<Child> children = new List<Child>();
>
> public IEnumerable<Child> {get{return children;}}
>
> public void AddChild(string name)
> {
> children.Add(new Child(this){Name= name});
> }
> }
>
> this allows my code to look like this
> session.Get<Parent>(id).AddChild("jason");
> NH will automatically save the changes when the session is flushed. and I
> have 1 location in which to manage adding children to the parent.
>
>
> > I was going to offer $10 to whomever decided to actually help.
> LOL. you don't get OSS do you :) not to mention the talent/value of the
> people assisting you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" 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/nhusers?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.