Hello
I have a problem adding entities to a collection.
public void SaveNotificationUsergroups(int bookingobjectID, int[] NotificationUsergroups)
{
BookingObject bo = _entities.BookingObjectSet.Where(b => b.BookingObjectID == bookingobjectID).First();
bo.UsergroupsBookingNotifications.Load();
int _currentUsergroupID;
for (int i = 0; i < NotificationUsergroups.Count(); i++)
{
_currentUsergroupID = NotificationUsergroups[i];
bo.UsergroupsBookingNotifications.Add(_entities.UsergroupSet.Where(ug => ug.UsergroupID == _currentUsergroupID).First();
}
_entities.SaveChanges();
}
I get an error on:
bo.UsergroupsBookingNotifications.Add(_entities.UsergroupSet.Where(ug => ug.UsergroupID == _currentUsergroupID).First();
that is:
cannot convert from 'BookingSystem.Data.Models.Usergroup' to 'BookingSystem.Data.Models.UsergroupsBookingNotifications'
In the database UsergroupsBookingNotifications has "int BookingObjectID" and "int UsergroupID"
whats needed to do?
/M
EDIT:
Tables:
Usergroups <---> UsergroupsBookingNotifications <--> Bookings