So I've got a conundrum that I can't think my way out of. Basically, I have a Book object with two properties, Title and ISBN. What I want to say is, from this list of Books, check the database for a Book that has a matching combination.
Naive code would look like so:
foreach( var book in BookList )
{
var matchingBook =
context.BookSet.Where( n => n.ISBN.Equals(book.ISBN )
&& n.Title.Equals(book.Title)).FirstOrDefault();
if( matchingBook )
....
}
Clearly, this is a sub-optimal solution, but I don't know how to get around this other than to iterate over the books, create a composite key (ISBN + "-" + Title) and then send that to the DB, but that's feels a little sloppy because indexes can't be used.
Any help is greatly appreciated.