I am using jquery full calendar and one of the things it has is an id that should be unique per appointment or the same per a bunch of appointments.
If you have the bunch of the same id’s then all those appointments are considered repeating appointments.
I want to generate a repeating id for each of my appointment and apply it to all the appointments that should have that repeating id.
I figured that the best way to do this would be to use the primary key of my appointment table.
Example
PK: 1, Title: Test1, Repeating Id: 1
PK: 2, Title: Test2, Repeating Id: 2
PK: 3, Title: Test2, Repeating Id: 2
PK: 4, Title: Test2, Repeating Id: 2
PK: 5, Title: Test3, Repeating Id: 5
So the first and last row don’t have any other rows that repeat with it.
Rows 2 to 4 do repeat with each other.
Now in my code I generate all the repeating rows before insert. Since nhibernate does batch inserts I do all my inserts at once. So at this time I do not know what the PK will be for any of the rows.
I am wondering can I somehow tell it to take the first item that should be inserted and find it’s PK out and apply it to all the following items repeatingId column?
Right now I can only think of one way to do that and that is insert the first item and then get the PK back and then batch insert all the other items after with the repeating id filled in.
I’m not sure how you will save the first element of a repeating group… but NH batches saves, not id assignments, so you can just do:
That said, I don’t understand why you are replicating the model that jquery uses in your model/DB.
Instead, you should use a normalized model (with RepeatingAppointment having a collection of Appointments) and project that when using it.