developing a new module in CodeSmith

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
9/19/2008 9:57:04 AM
Gravatar
Total Posts 69

developing a new module in CodeSmith

Hi,

am I missing somethign glaringly obvious? I am trying to write a new module using CodeSmith. I have never used ASP.NET before in any form so it's a big learning curve for me.

the problem is I can't find out how to hook up to the data in the database. I've got a MySql database up and running and the rest of the mojoPortal site works with it fine. I added a new table with some sample data in but how do I display that data in my module?

9/22/2008 6:34:49 AM
Gravatar
Total Posts 69

Re: developing a new module in CodeSmith

sorry, meant to add that I'm trying out the 'Inline code info' from the developer docs

9/22/2008 6:48:32 AM
Gravatar
Total Posts 18439

Re: developing a new module in CodeSmith

The scripts don't produce a turnkey solution, you have to wire it all up and you need to understand the generated code and modify it as needed.

The way I would do it is:

1. createthe table, make sure it has a primary key

2. use the MSSQL stored procedure Codesmith template to generate procs

3. use the MS SQL Data Access template to generate data access code

4. use the Business class stubber template to generate a business class

5. generate the module control (I would not use the inline one myself)

6 use one of the mp_Table_ToGridView-IListBinding template to generate some usefull chunks of code for the gridview to copy an past into my control

I would use external projects with code behind. You "could" use the inline example and put all the data and business logic classes right in the control, but I like to have them separated projects per layer myself. I don't like to put data access code in my web code.

Hope it helps,

Joe

9/22/2008 9:50:13 AM
Gravatar
Total Posts 69

Re: developing a new module in CodeSmith

thanks Joe - I'm totally new to ASP.NET so please forgive the newbie questions

I also should have said it's working from a MySQL database rather than an MSSQL one so I'm guessing I just substitute the MySQL stored procedure instead.

9/22/2008 10:00:41 AM
Gravatar
Total Posts 18439

Re: developing a new module in CodeSmith

If you're using MySql it should work as long as you have the newer 4.x version of Codesmith. I'm pretty sure it can be used to generate against MySql tables.

Our Codesmith templates don't crerate MySql stored procedures, the sql statements are generated right in the DataLayer code so you can skip the step about stored procedures for MySql. Its more work having to maintain the stored procedures anyway. I do use stored procs for MS SQL because I've done so since the beginning, but MySql didn't even support stored procs when we started using it and I can't see any real reason to start using them now when its more work to do so and none of the existing code uses them for MySql and any supposed performance benefits of using procedures is so small it would be hard to measure. So I go for the easy maintenance using no stored procs for MySql. We just build the sql statements using StringBuilder.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.