public static void BookNoteSave(BookDataContext bookdb, UserNote note)
        {
            var bn = CommonQueries.BookNotesFind(bookdb, note.BookId);

            if (bn == null)
            {
                bn        = new BookNotes();
                bn.BookId = note.BookId;
                CommonQueries.BookNotesAdd(bookdb, bn, CommonQueries.ExistHandling.IfNotExists);
                bn = CommonQueries.BookNotesFind(bookdb, note.BookId);
            }
            if (note.Id == 0) // Hasn't been saved before. The id is 0.
            {
                bn.Notes.Add(note);
            }
            CommonQueries.BookSaveChanges(bookdb);
        }
        public static int BookNotesAdd(BookDataContext bookdb, BookNotes bn, ExistHandling handling)
        {
            int retval = 0;

            NQueries++;
            var book = BookGet(bookdb, bn.BookId);

            if (book == null)
            {
                return(retval);
            }
            switch (handling)
            {
            case ExistHandling.IfNotExists:
                if (book.Notes == null)
                {
                    book.Notes = bn;
                    retval++;
                }
                break;
            }
            return(retval);
        }