 |
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
|
|
|
|
|

January 14th, 2009, 11:49 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
LINQ: Chapter 13, the first example cannot be run
I'm now having a question want to ask somebody here:
In chapter 13 LINQ, the first example of LINQ, there is a line of C# script:
var allReviews = from review in my DataContext.Reviews
When I try to run it in IE, it prompt errors. Does anybody knows why?
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'PlanetWroxDataContext' does not contain a definition for 'Reviews' and no extension method 'Reviews' accepting a first argument of type 'PlanetWroxDataContext' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 18: using (PlanetWroxDataContext myDataContext = new PlanetWroxDataContext())Line 19: {Line 20: var allReviews = from review in myDataContext.ReviewsLine 21: where review.Authorized == trueLine 22: orderby review.CreateDateTime descending
|
|

January 15th, 2009, 03:26 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Clark,
Couple of questions:
1. Do you have a non-English OS? If that's the case, the table name may not have been pluralized automatically by VWD in which case you need to change it in the diagram, or refer to myPlanetWroxDataContext.Review instead
2. Is your DataContext indeed called PlanetWroxDataContext?
3. Did you compile (right-click the web site and choose Build) before you tried to access the Reviews collection?
4. Do other tables pop up in the IntelliSense list for myPlanetWroxDataContext?
Imar
|
|

January 15th, 2009, 05:07 AM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It's so glad to see the prompt response from the author!
Mr. Imar, pls see my comments below:
Quote:
Originally Posted by Imar
Hi Clark,
Couple of questions:
1. Do you have a non-English OS? If that's the case, the table name may not have been pluralized automatically by VWD in which case you need to change it in the diagram, or refer to myPlanetWroxDataContext.Review instead
[Clark]OS: Vista Business English/VS2008 Pro Chinese
2. Is your DataContext indeed called PlanetWroxDataContext?
[Clark]YES.
3. Did you compile (right-click the web site and choose Build) before you tried to access the Reviews collection?
[Clark]When I try to compile it, the error shows: 错误 1 'PlanetWroxDataContext' does not contain a definition for 'Reviews' and no extension method 'Reviews' accepting a first argument of type 'PlanetWroxDataContext' could be found (are you missing a using directive or an assembly reference?) D:\Csharp\ASP35\Site\Reviews\All.aspx.cs 20 59 D:\...\Site\
4. Do other tables pop up in the IntelliSense list for myPlanetWroxDataContext?
[Clark]No. Nothing happens.
Imar
|
|
|

January 15th, 2009, 06:01 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Two things to try:
1. Comment out all offending code and recompile and then try again.
2. Does this work:
PlanetWroxDataContext myContext = new PlanetWroxDataContext();
Does that compile?
Imar
|
|

January 15th, 2009, 06:56 AM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Have done with you instructions.
It works:
PlanetWroxDataContext myContext = new PlanetWroxDataContext();
But still need to remove the "s" from
var allReviews = from review in myDataContext.Reviews.
|
|

January 15th, 2009, 07:24 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Yeah, that's what I was afraid off. On non-english versions of Visual Studio, names of objects are not automatically pluralized.
For more info: check out the errata for page 430 here: http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html
Cheers,
Imar
|
|

January 15th, 2009, 08:41 AM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
|
Got it! Thanks!   
|
|
 |