Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2012, 03:51 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile single review for every genre

Hi Imar I want to show recently added (single) review for every genre on a page, and on clicking genre name I will show all reviews falling in that genre but I am having some problem.
I am not getting any way to show only single review with every genre.
How I can change this code so that it works...

Code:
using (PlanetWroxDataContext myDataContext = new PlanetWroxDataContext())
{
var allGenres = from genre in myDataContext.Genres
orderby genre.Name
select new { genre.Name, genre.Reviews };
Repeater1.DataSource = allGenres;
Repeater1.DataBind();
}
In design view I am using repeater and datalist controls.
 
Old October 21st, 2012, 06:56 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

H there,

You need to call FIrst() on the Reviews collection with a reversed sort order. Take a look at page 436 for an example.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 23rd, 2012, 04:17 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

I looked at that query but It is just for reviews but not the Genre and Reviews Combined.

How I return latest review for every genre using repeater/datalist controls or by other means?
Thanks
 
Old October 24th, 2012, 06:46 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can us the exact same concepts here. Just call First():

genres.Reviews.First()

However, that returns a single Review, not a collection so you need to change the control or code to display the review.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Review assigned to multiple Genres sophia BOOK: Beginning ASP.NET 4 : in C# and VB 12 January 17th, 2012 07:32 AM
CH 17 Storing Genre Preferences in the Profile - Error! leeWozyWarren BOOK: Beginning ASP.NET 4 : in C# and VB 3 December 7th, 2011 01:20 PM
Retrieving a single value from a single column in a single row? Ron Howerton LINQ 2 May 17th, 2011 08:46 AM
Genre and Show objects association vyurik BOOK: Professional Java Development with the Spring Framework 0 July 6th, 2006 06:00 AM
ASP.Net Single Single-on with Oracle Application S guhanath Oracle 0 October 6th, 2004 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.