views:

122

answers:

2

I am working in a .NET 2.0, recently upgraded to .NET 3.5 environment (VS2008, VB.NET) on an existing ASP.NET website project. I am able to generate a Linq-to-SQL Class (also called a DataContext?) in the App Code folder, drag over tables from an active connection, and save it. Let's call it MyDB. When I go to the code-behind file for my page and try to declare an object of "MyDBDataContext" it is not in the intellisense, indicating that it is not accessible. I checked the references, and that has to be set correctly because I made the .dbml file. I made a new test windows app project and it behaved exactly as expected, and I could follow this blog without a problem.

Is there something inherent to web projects that doesn't allow for these auto-generated objects to be usable? Is App Code the right place to declare it?

If you can't tell from the above, I am new to the industry and really new to LINQ.

thanks for your help.

+2  A: 

Try expanding the dbml file and open the designer.cs file underneath, and make sure the DataContext class is in the same namespace as the codebehind class. If not, either change the namespace or include it with a using Namespace statement the top.

Rex M
great! thanks, that was it... just needed the basics re-explained.
Watki02
A: 

If it your dbml is in a folder inside of '/App_Code/' it may pick up the folder's name as a namespace. Eg: '/App_Code/DAL' would have the namespace 'DAL'. Give it a namespace in the designer or just use the namespace it is given, if this is the case.

Joe Flateau
this answer was a bit more thorough, and very helpful! thanks
Watki02