I ran into a minor problem and was wondering if anyone have a solution. I recently build a Project on VS 2010. I created a Linq to SQL class in a folder call NorthWind. When I'm writing the code behind. I notice that I have to type "NorthWind.NorthWindDataContext
db = new NorthWind.NorthWindDataContext(); instead of just NorthWindDataContext db = new NorthWindDataContext(); . I know that when creating a Web Site, Linq to Sql class will be store in App_Code folder and I can just refer to it "NorthWindDataContext". Is
there a configuration to eliminate the NorthWind. pointer?
PS: If I was to create the Linq to Sql class on the root of the Project, it work without the NorthWind. pointer.
There are two ways you can try either or both of them:
1)Try to switch the generated dmbl file in the App_Code,see the property panel(right-down),Make sure that the propety——“BuildAction”is "Compile"。Thus you should rebuild all the solution to refer the namespace。
2)Move the dbml file wholly out of the App_Code and rebuild your solution,and then refer the namespace。
Just incase a newbie like myself need help on this...
Decker Dong - MSFT
Hello:)
There are two ways you can try either or both of them:
1)Try to switch the generated dmbl file in the App_Code,see the property panel(right-down),Make sure that the propety——“BuildAction”is "Compile"。Thus you should rebuild all the solution to refer the namespace。
2)Move the dbml file wholly out of the App_Code and rebuild your solution,and then refer the namespace。
aspn00bie
Member
111 Points
75 Posts
Linq to SQL
Feb 01, 2012 03:49 PM|LINK
I ran into a minor problem and was wondering if anyone have a solution. I recently build a Project on VS 2010. I created a Linq to SQL class in a folder call NorthWind. When I'm writing the code behind. I notice that I have to type "NorthWind.NorthWindDataContext db = new NorthWind.NorthWindDataContext(); instead of just NorthWindDataContext db = new NorthWindDataContext(); . I know that when creating a Web Site, Linq to Sql class will be store in App_Code folder and I can just refer to it "NorthWindDataContext". Is there a configuration to eliminate the NorthWind. pointer?
PS: If I was to create the Linq to Sql class on the root of the Project, it work without the NorthWind. pointer.
Any idea or thought on this?
seamus1982
Participant
936 Points
375 Posts
Re: Linq to SQL
Feb 01, 2012 03:55 PM|LINK
Hi,
At the top of your code include the file where the using statements are.
i.e
using NorthWind;
Then you won't have to give the full name.
Regards,
Seamus
aspn00bie
Member
111 Points
75 Posts
Re: Linq to SQL
Feb 01, 2012 04:16 PM|LINK
That won't work, already try that before I post. There is no such using statement.
thaicarrot
Contributor
5120 Points
1459 Posts
Re: Linq to SQL
Feb 01, 2012 07:01 PM|LINK
Hi,
Just right then>> Properties>> Custom tool NameSpace.
Weera
govindaraj
Member
168 Points
53 Posts
Re: Linq to SQL
Feb 02, 2012 08:21 AM|LINK
Hi,
You need to add namespace for the datacontext.
or other approach would be like adding the datacontext namespace using.
Hope this help u...
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Linq to SQL
Feb 03, 2012 12:13 AM|LINK
Hello:)
There are two ways you can try either or both of them:
1)Try to switch the generated dmbl file in the App_Code,see the property panel(right-down),Make sure that the propety——“BuildAction”is "Compile"。Thus you should rebuild all the solution to refer the namespace。
2)Move the dbml file wholly out of the App_Code and rebuild your solution,and then refer the namespace。
Reguards!
aspn00bie
Member
111 Points
75 Posts
Re: Linq to SQL
Feb 15, 2012 05:41 PM|LINK
Awesome....I never full understand it until I read your response with the addition of this:
http://forums.asp.net/t/1420536.aspx/1
Just incase a newbie like myself need help on this...