for simple collections (non-dictionary):

i have my Domain posted here: http://j.mp/eOI3qS

1) What is the difference between AsBag() and AsList(), and how can i use
AsList()? Should I?
2) Are the KeyColumn, Column, and ForeignKey all required? What do the
various combinations of these methods mean?
3) If I use Not.LazyLoad() on NoteMap, do I need to use it on HasMany()?
4) What takes precedent for Cascade, when it's set on both? What does that
really mean in both cases (on the HasMany & References, respectively)?
5) How does Inverse affect the save behavior? Is it appropriate for all
cases?

In short: I haven't been able to get this working for both load, and save,
without either breaking the load or the save, or removing constraints from
my database.

This is a nHib question ply (except how it is affected by my fluent
mappings..), but in my app, if I have a new Ticket with 3 notes created
Client-side, and RIA sends them over the wire to be saved, and if the Notes
are 'inserted' into my server-side datamodel before the Ticket, the save
fails, even though I'm persisting them in a transaction after all have been
added to the Session. If I force the Ticket to be inserted into the Session
before the notes, it works, but only if I remove the FK relationship on the
Note table. In addition, if the save completes, the FK's on the Notes aren't
updated with the generated ID of the Ticket. In other instances, if I'm
adding a note to an existing ticket, RIA won't send back the ticket instance
over the wire, but my TicketID field is populated with it. However, NHib
tries to insert a null, assumingly because Ticket was null, so TicketID
couldn't be gleaned from the instance.

TBH, I can't imagine it's very helpful to try and explain all the possible
mapping combinations I've tried, all the saving orders I've tried, and all
the resulting errors. The above problems are just a small sampling from
that. I think it would be a lot better to know how it should be done given
my data model, mappings, and schema (which can be changed to make it work as
it should).


public class TicketMap : ClassMap<Ticket>
{
        public TicketMap()
        {
            this.Not.LazyLoad();
            this.Table("TICKETS");

            this.Id(x => x.TicketID, Fields.TICKET_ID)
                .GeneratedBy.Sequence("SEQ_TICKET_ID");

            this.HasMany<Note>(x => x.Notes)
                .KeyColumn(Fields.TICKET_ID)
                .Not.LazyLoad()
                //.AsList();
                //.Inverse()
                //.Cascade.AllDeleteOrphan();
         }
}

public class NoteMap : ClassMap<Note>
{
        public NoteMap()
        {
            this.Not.LazyLoad();
            this.Table("NOTES");

            this.Id(x => x.NoteID, Fields.NOTE_ID)
                .GeneratedBy.Sequence("SEQ_NOTE_ID");

            this.References(x => x.Ticket)
                .Column(Fields.TICKET_ID)
                .ForeignKey(Fields.TICKET_ID)
                .Not.Nullable()
                //.Cascade.All()
                ;
         }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to