I have 2 table Reservation Guest
Reservation has a FK to Guest (GuestId)
When I add a new reservation I have to call AddTo on both objects for it to work. Which is fine, but I was thinking I should be able to set the guest object in the Reservation initializer and just call AddTo on the reservation object.
Is this the correct approach or am I missing something?
                var guest = new Guest
             开发者_JS百科   {
                    GuestId = Guid.NewGuid(),
                    LastName = item.Guest.LastName,
                    FirstName = item.Guest.FirstName
                };
                var reservation = new Reservation
                {
                    ReservationId = Guid.NewGuid(),
                    GuestId = guest.GuestId,
                    //Guest = guest,
                    ReservedDtm = item.Date
                };
                _context.AddToGuests(guest);
                _context.AddToReservations(reservation);
Create the guest and use addObject(newguest) on the context. After that create the reservation and add the guest to it. That should work. I type from my smartphone so forgive me the missing formatation.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论