Untitled

mail@pastecode.io avatar
unknown
csharp
7 months ago
1.0 kB
2
Indexable
Never
    [Fact]
	public async Task TestSomething()
	{
		using (var db = new DB())
		{
			string membersFirstname = "Zondra";

			//...write the query/queries here; keep in mind that only SELECT queries are valid...
			var response = await db.Authors
				.Join(db.Books,
					author => author.Id,
					book => book.Author.Id,
					(Author, book) => new { Author, Book = book })
				.Join(db.Loans, 
					combined => combined.Book.Id,
					loan => loan.Book.Id,
					(combined, loan) => new { combined.Author, combined.Book, Loan = loan })
				.Join(db.Members, 
					combined => combined.Loan.Member.Id, 
					member => member.Id, 
					(combined, Member) => new { combined.Author, combined.Book, combined.Loan, Member })
				.Where(result => result.Member.Firstname == membersFirstname)
				.Select(result => result.Author.Firstname)
				.FirstOrDefaultAsync();

            //...add assertions to test the results or run of query/queries here...
            Assert.Equal("Zulema", response);
		}
	}
Leave a Comment