Пример #1
0
        public void RemoveUserRoom(ChatUser user, ChatRoom room)
        {
            RunNonLazy(() =>
            {
                // The hack from hell to attach the user to room.Users so delete is tracked
                ObjectContext context      = ((IObjectContextAdapter)_db).ObjectContext;
                RelationshipManager manger = context.ObjectStateManager.GetRelationshipManager(room);
                IRelatedEnd end            = manger.GetRelatedEnd("JabbR.Models.ChatRoom_Users", "ChatRoom_Users_Target");
                end.Attach(user);

                room.Users.Remove(user);
            });
        }