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 January 14th, 2009, 11:49 PM
Authorized User
 
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Angry 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
 
Old January 15th, 2009, 03:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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 January 15th, 2009, 05:07 AM
Authorized User
 
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's so glad to see the prompt response from the author!

Mr. Imar, pls see my comments below:

Quote:
Originally Posted by Imar View Post
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
 
Old January 15th, 2009, 06:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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 January 15th, 2009, 06:56 AM
Authorized User
 
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old January 15th, 2009, 07:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
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 January 15th, 2009, 08:41 AM
Authorized User
 
Join Date: Jan 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Quote:
Originally Posted by Imar View Post
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
Got it! Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
LINQ Error ? Chapter 13 workidoo BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 July 22nd, 2008 09:37 AM
run time error 13 selamiduvar VB Databases Basics 1 May 1st, 2006 04:54 PM
run-time error 13: type mismatch bryan.lugo Excel VBA 2 April 19th, 2006 04:39 AM
run time error 13 selamiduvar Access VBA 3 March 7th, 2006 07:46 PM
run time error 13 selamiduvar Pro VB 6 1 March 7th, 2006 08:08 AM





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