Created
October 9, 2016 02:48
-
-
Save Programazing/a9712aa11001658bfdbc123b94666e8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var book = (from theBook in _context.Books.Where(b => b.BookId == id) | |
join loan in _context.BookLoans.Where(x => !x.ReturnedOn.HasValue) on theBook.BookId equals loan.BookID into result | |
from loanWithDefault in result.DefaultIfEmpty() | |
select new BookDetailsViewModel | |
{ | |
BookID = theBook.BookId, | |
SubTitle = theBook.SubTitle, | |
Title = theBook.Title, | |
Author = theBook.Author, | |
ISBN = theBook.ISBN, | |
GenreName = theBook.Genre.Name, | |
DeweyName = theBook.Dewey.Name, | |
StudentID = loanWithDefault.StudentID, | |
IsAvailable = loanWithDefault == null, | |
AvailableOn = loanWithDefault == null ? (DateTime?)null : loanWithDefault.DueOn | |
}).FirstOrDefault(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment