Forum


HomeHomePremiumPremiumDevelopmentDevelopmentLINQ2SQL as database connection?LINQ2SQL as database connection?
Previous
 
Next
New Post
9/10/2014 1:17 AM
 

Hi!

I'm not an expert programmer, but I once developed modules for DNN 5.x using some tutorials by Michael Washington.
We used LINQ2SQL as the way for connecting to the database. It was extremely easy!

I tried the same approach here using Christoc's templates, but I couldn't make my .cs file "see" the DataContext object defined in the xxx.designer.cs within the App:Code folder.

Is it impossible to use those LINQ2SQL approach?

If not, how can I do that?

Thanks!

 
New Post
9/11/2014 4:35 AM
 

Adrian,

I'm sure you can use Linq2SQL in your module.  I don't have an example now, but you may be able to use the technique I showed in the Data Access Techniques video to use a partial class with the same name as your DataContext class to set the connection string to your DNN connection.

I'm not sure what you mean by your .cs file can't "see" the DataContext?  Are you saying that you can't access the DataContext object from another class because of a namespace issue perhaps?

 

 
New Post
9/11/2014 9:31 AM
 

Hi Andrian/Scott,

Can you please let me know if you get a notification about this post? I'm trying to troubleshoot some email problems the forum is having.

Thanks,

Aderson

 
New Post
9/12/2015 6:38 AM
 

Hi Scott.

It's been a while since my last post here, and I really stopped trying to use LINQ2SQL with Christoc's Module Templates. But now I'm back, and I stil can't figure it out!

Allow me to give a brief historic review of my experience creating modules: what I've been doing so far is creating a folder inside of Desktopmodules with the name of my company, and inside of it one folder for each module I made, and inside of each folder an .ascx file with its .ascx.vb associated file. And for the data connection I created a folder called App_Code, and inside of it I created a "LINQ2SQL Classes" set of files. To populate gridviews, combos, formviews, I just dropped a Linq2sqlDtasource on the .ascx and within it I chose the LINQ2SQL datacontext that is in the App_Code folder. And to Access the database from the .ascx.vb (codebehind) file, I created a datacontext type variable, and from it I reached tables, stored procedures, views, etc. in the database.

That's it. It Works nice, but I cannot create "true" modules, instalable .zip modules.

With Chirstoc's templates I can create those modules, which is great. But triying to use the same LINQ2SQL approach for databinding and data Access in general, is still impossible.

I've obtained curious results:

1- I added an App_Code to the Project (right click -> Add/Add ASP.net Folder/App_Code, and my LINQ2SQLDatasources on the .ascx files get the DataContext in them. BUT I cannot access the Datacontext from my code. :( -oh, and I must create an App_Code folder with a copy of the Datacontext files in it, on the DNN server.

2- If I create a LINQ2SQL datacontext in the root folder of the module, I can use it from my vb code file, but it won't appear on my LINQ2SQLDtasources!

I tried to use the partial class approach, but honestly, maybe I'm not that proficient in .NET and I couldn't do it.

BTW, I tried populating a gridview using a plain SQLDatasource, and it worked flawlesly. Why cannot one use that approach for module creation?

Thanks for your comments.

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentLINQ2SQL as database connection?LINQ2SQL as database connection?



Try FREE
30 days money back guaranteed