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

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a... How can I see the file that has the SQL script in a Template MVC Module? How can I see the file that has the SQL script in a Template MVC Module?
Previous
 
Next
New Post
4/8/2019 5:44 PM
 

Hi Everyone !!

I have created an MVC module template from the package offered by Chris-Hammod https://marketplace.visualstudio.com/...

Effectively and as he explains in his videos, I have a basic module that removes, creates, reads and updates a list of elements with a name and a description.

I am trying to understand all the code to be able to start creating my own and I can not find the script that executes to read, create, delete and edit the elements of the list.

I run an SQLProfiler and I could tell that it does the scripts with a sp_executesql: EJ

exec sp_executesql N'DELETE FROM [DNNModuloPropio_Items] WHERE [ItemId] = @ 0 ', N' @ 0 int ', @ 0 = 3

My problem is that I even debug the code and I can not see where that "DELETE FROM" or "INSERT INTO" is stored. Everything comes to this class and it ends there.

 

 

public void DeleteItem (Item t)

{

  using (IDataContext ctx = DataContext.Instance ())

  {

     var rep = ctx.GetRepository <Item> ();

     rep.Delete (t);

  }

}

 

I remain attentive to your support, thank you very much!

 
New Post
4/9/2019 1:53 AM
 
Hi,

The magic is behind DotNetNuke.Data.DataContext class. It's a micro ORM tool that automatically creates SQL statements. It's similar thing like in Linq 2 Sql, Entity Framework, PetaPocoDataContext, etc So in theory developer doesn't need to know SQL to work with databases. See here for reference:
https://www.dnnsoftware.com/community...
https://www.dnnsoftware.com/wiki/dal-...
 
New Post
4/9/2019 1:58 AM
 
Arnell,

the code is generated by DAL2 (which is more or less the implementation of PetaPOCO in DNN). Nothing to care about...

If you need to execute Stored Procedures you should look at the DAL2 documentation or a module that uses it. The following blog article could be helpful: https://www.dnnsoftware.com/community...

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
4/11/2019 12:28 PM
 
Barry Waluszko wrote:
Hi,

The magic is behind DotNetNuke.Data.DataContext class. It's a micro ORM tool that automatically creates SQL statements. It's similar thing like in Linq 2 Sql, Entity Framework, PetaPocoDataContext, etc So in theory developer doesn't need to know SQL to work with databases. See here for reference:
https://www.dnnsoftware.com/community...
https://www.dnnsoftware.com/wiki/dal-...

Hello barry!


Now if I have an idea of ​​how all this works in DNN, I made a test creating a new module, added 3 new columns to the table and added the respective classes that would refer to those tables. Indeed, I did not have to write any extra SQL code nor a class that executed the queries to insert, update, delete or obtain the new data.
One last question. Will you have articles that talk about how to execute my own storage procedures?

 
New Post
4/12/2019 2:38 AM
 
Arnell,

the link I inserted in my above post has an example how to execute a stored procedure.

Also this blog post could be helpful: http://www.bitboxx.net/Blog/Post/190/...

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a... How can I see the file that has the SQL script in a Template MVC Module? How can I see the file that has the SQL script in a Template MVC 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