Pardon if title is improper..
How to write below sql query with linq to sql without dividing it in multiple parts?
select BookName,
Author,
TotalCopies=(select COUNT(*)
from tbEHBookCopies c
where c.BookID=b.BookID)
from dbo.tbEHBooks b
I'm not sure what you mean by multiple parts. If you mean that it should be on one single query then you could do something like:
Using query syntax joining and grouping. Linq-sql is just a little different when it comes to grouping. The nice thing about this syntax is that it is easy to join in more tables. And it looks more like a SQL query only the "from" comes first, and the "select" comes last.