How to create a data module

Topics: Writing modules
Apr 25, 2012 at 9:21 AM

Hey everyone,

I'm new to orchard and I was wondering if somebody could explain to me the steps I need to perform to create a module with data access.

I have an excisting MVC3 app (I don't need to convert it) with a sql database to add employees to a school (many to many relation), the school can be in one department)

Do I need to create the tables first in the existing Orchard database and how can I finally get the editors of the site to add employees and have them displayed on my site?

Tx,

Borrie

Apr 25, 2012 at 2:36 PM

You're app should (theoretically) work "as-is" as an Orchard Module provided you suppress Orchard's ambient transaction.

using (var scope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Suppress)) {
                
}
That code could be wrong, I am pulling it from memory, You'll need to suppress the transaction to do any data access outside of orchard, i.e to your existing SQL database. 

Apr 26, 2012 at 12:30 PM

Reverand,

Tx for your answer, i'm following the pluralsight video's now to add database tables and stuff in an existing orchard site, I've got a loooong way to go :)

Just for Info, say I want to display a module in a separate div on my _Layout.cshtml page , in my existing MVC3 app i use ajax.actionlink, how can I do that in Orchard? (does the _Layout page even exist? :) )

Borrie

Apr 26, 2012 at 3:53 PM

_Layout.cshtml doesn't exist exactly; the equivalent is the Layout.cshtml file in your Theme. The theme can be a custom one, the default orchard one, or one you download from the Orchard gallery. 

Apr 27, 2012 at 1:38 PM

Monarch,

Tx, I found the files and it's almost the same so no problem.

I have one last question, I want to create a menu on the left side (that shouldn't be a problem normally) but when you click on a menu item i want to display a page with tabs, per tab i want a different page where the editor can add or change the text via tinymce.

How can I do that?