Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Using Linq To SQL in WAP moduleUsing Linq To SQL in WAP module
Previous
 
Next
New Post
9/16/2008 3:52 PM
 

I'm using the C# Compiled Module Starter Kit from BiteTheBullet.co.uk (Thanks Mark!).  I've successfully compiled the sample module project created by the starter kit.

Now I want to create my own data access layer using Linq To SQL and when I create a new data context, I can't figure out how to tell it to use the same database connection that DNN is using for the site.  In Michael Washington's tutorial, one of the options in the drop down list for the "Connection" property is "SiteSqlServer" -- the key for the connection string in the web.config file.  But Michael's Linq To SQL tutorial uses the web site model, and that option is not available when creating a module using the WAP model.

It seems like the problem is related to the fact that VS2008 sees the WAP module you are developing as existing in it's own web site -- VS keeps generating a web.config in the same folder as the module.

Anybody figure out how to do this yet?  I did search the forums (as well as the web) for information about how to make a WAP project use the web.config from a parent directory, but no luck.

Thanks,

Michael Bradley

 
New Post
9/16/2008 8:41 PM
 

All you have to do is create a "SiteSqlServer" key in the web.config of the project that the LinqToSql project is in and configure it to use it. When the module is compiled into the DotNetNuke site it will read the configuration setting from there. Make sure you have "Application Settings" set to true on the LinqToSql class.

This is also what is happeneing when you make a WSP module. You are using the "SiteSqlServer" key on your development machine then uploading the module to your production machine. The LinwTOSql is using whatever the current value is for the "SiteSqlServer" key .



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
9/19/2008 5:28 PM
 

Thanks for your reply Michael (and thanks for all your tutorials).

I did as you suggested.  I created a connection strings section in the web.config file located in the WAP project for my DNN module, and duplicated the "Site Sql Server" section from the web.config in the DNN website I'm using for development.  VS 2008 still does not provide that option in the drop down list for the connection property in any Linq to SQL data context I create.

Actually, I think I need to step back and give more details about my setup and what I have learned so far. 

I am starting off with the project created by the BiteTheBullet starter kit.  I have the install version of DNN running from c:\Dnn using the local IIS.  I'm running this development DNN environment utilizing the database.mdf file located in c:\Dnn\App_Data running as a user instance on my local SQLExpress.

I have a VS2008 solution, created using the BiteTheBullet starter kit whose files are located in c:\Dnn\DesktopModules\MyWapModule\.  The MyWapModule project has a reference to DotNetNuke.dll (located in c:\Dnn\bin) and builds to c:\Dnn\bin.

If I compile the basic module provided by the BiteTheBullet starter kit project, and install the module in my DNN site via the usual method, all is well.

Now I want to replace the DAL with one that utilizes Linq to Sql.  First I need to create a DataContex (.dbml file).  In order to do so, I need to drag tables from the Server Explorer to the Linq to SQL design surface (I would prefer not to use SqlMetal to do it) -- but the MyWapMoodule project does not have a data connection to the database my DNN installation is using.  I can't directly attach the same database file as DNN is using from the MyWapModule project because the ASPNET process running DNN already has a hold of it. 

I CAN use the SSEUtil tool to find the name of the user instance that DNN's ASPNET process is using (e.g., \\.\pipe\xxxxxx-xxxx-xx\tsql\query) and then create a data connection to it.  I can then drag tables from this connection onto the design surface in order to create Linq To Sql DataContext classes, however the connection string property in the designer is then specific to the user instance that the ASPNET process is using to run my development DNN environment -- this connection string will not work for the DataContext classes when they are moved to production.

I can also set the DataContext's connection string property to "none."  If I do this, when I instantiate an instance of the DataContext in code, I can do so using the constructor overload that calls for a connection string and pass in the value returned by DotNetNuke.Common.Utilities.Config.GetConnectionString("SiteSqlServer").  This should work properly in both development and production (haven't tested moving the module from development to production yet).

What I'm wondering about though, is if there is a way to make the MyWapModule VS project understand that it is running as a subfolder (not a separate app) of the DNN installation so that the project can "see" DNN's web.config file and allow the DataContext designer to provide the option to connect using the "SiteSqlServer" connection defined there.  As I said, that option did not appear in the DataContext designer's connection property drop down box -- even after i added a "SiteSqlServer" key to a web.config that is local to the project folder.

Thanks to anyone who's taken the time to read through this.  And thanks in advance for any help.

Michael Bradley

 
New Post
9/19/2008 6:24 PM
 

I have to admit I am not getting a "warm fuzzy feeling" for the process you are using. Linq to SQL is fun and easy. I really mean that. It's a joy to work with and I absolutely will not go back to doing things the old way. The process you descibes has none of that.

The following tutorial shows a WSP module but the web service proxy Project is using the WAP method. Perhaps it can provide some ideas of things you could try:
http://www.adefwebserver.com/DotNetNukeHELP/Workflow/VacationRequest.htm

If this project used LIinqToSQL it would work as expected. I know this because I use the same method for this project that compiles into this project.

Perhaps the BiteTheBullet template is based on VS 2005 and VS2008 default project is actually improved? Or perhaps I am not making Web Application Projects, but just projects and that is why it is working for me?

 



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
9/22/2008 11:55 AM
 

You should not have a web.config inside the WAP module. In a WAP project you can have a project URL and an override root so the project reads info from the holding website web.config. Check the Announcements source for an example. I have not tackled Linq just yet with WAP but as soon as I do I will post info at the DNN blog.


Do you know the truth when you hear it?
Néstor Sánchez
The Dúnadan Raptor -->Follow Me on Twitter Now!
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Using Linq To SQL in WAP moduleUsing Linq To SQL in WAP module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out