|
-
February 11th, 2009, 05:38 PM
#1
All books by a certain publisher [LINQ]
Sorry for asking again but this is important for me:
I have two tables:
[publishers](
[pub_id] [char](4) NOT NULL,
[pub_name] [varchar](40) NULL,
[city] [varchar](20) NULL,
[state] [char](2) NULL,
[country] [varchar](30) )
and
[titles](
[title_id] [dbo].[tid] NOT NULL,
[title] [varchar](80) NOT NULL,
[type] [char](12) NOT NULL DEFAULT ('UNDECIDED'),
[pub_id] [char](4) NULL,
[price] [money] NULL,
[advance] [money] NULL,
[royalty] [int] NULL,
[ytd_sales] [int] NULL,
[notes] [varchar](200) NULL,
[pubdate] [datetime] NOT NULL
How can I get all the books from a certain publisher in one linq query:
The result should be something like that
Publisher 1
book1
book2
..
Publisher 2
book1
book2
..
I am a bit new to LINQ and I don't quite handle it well.
The tables above are from Nothhwind, so I am learning on them.
-
February 11th, 2009, 08:59 PM
#2
Re: All books by a certain publisher [LINQ]
how would you do that in a normal SQL query?
-
February 12th, 2009, 12:27 AM
#3
Re: All books by a certain publisher [LINQ]
Why only one statement? LINQ is powerful, but you don't have to make it one-line.
I'd create the list of authors, and then query the books table for each author in the first list. you can order in each one.
You'd loop thru both tables to output
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|