public IEnumerable<Book> GetAllBooksBy(Author author) { // TODO : check if this magic works return from b in this.context.Books join ab in this.context.AuthorBooks on b.ISBN equals ab.BookISBN where author.Id==ab.AuthorId select b; /*SELECT * FROM Book b JOIN AuthorBook ab ON b.ISBN = ab.BookISBN JOIN Author a ON a.Id = ab.AuthorId */ }
public IEnumerable<Genre> GetAuthorGenres(Author author) { // TODO : abra-cadabra works? return from g in this.context.Genres join bg in this.context.BookGenres on g.Id equals bg.GenreId join b in this.context.Books on bg.GenreId equals b.GenreId join ab in this.context.AuthorBooks on b.ISBN equals ab.BookISBN where author.Id==ab.AuthorId select g; /*USE HackLibrary SELECT * FROM Genre g JOIN BookGenre bg ON g.Id=bg.GenreId JOIN Book b ON b.GenreId=bg.GenreId JOIN AuthorBook ab ON ab.BookISBN=b.ISBN JOIN Author a ON ab.AuthorId=a.Id */ }
public bool Insert(Author author) { try { this.context.Authors.InsertOnSubmit(author); this.context.SubmitChanges(); } catch (SqlException e) { Console.WriteLine(e.Message); return false; } return true; }
partial void DeleteAuthor(Author instance);
partial void UpdateAuthor(Author instance);
partial void InsertAuthor(Author instance);