Generating BusinessClassStub results in "type ... already contrains a definition for .. "

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.
10/13/2008 2:03:37 AM
Gravatar
Total Posts 8

Generating BusinessClassStub results in "type ... already contrains a definition for .. "

Hi,

I created a new module following this staps.

  1. Created two tables hm_HOUSE, hm_HOUSE_TYPE
  2. Generated Stored Procedures (CodeSmith)
  3. Generated MSSQL DAL code - not using SubSonic (CodeSmith)
  4. Generated Business Class Code (CodeSmith)

When i try to build this, i get the following errors:

Error 66 The type 'HouseModule.Business.HOUSE' already contains a definition for 'hot_id' D:\dev\mojoportal\HouseModule.Business\House.cs 81 20 HouseModule.Business
Error 63 The type 'HouseModule.Business.HOUSE' already contains a definition for 'hou_description' D:\dev\mojoportal\HouseModule.Business\House.cs 66 23 HouseModule.Business
Error 65 The type 'HouseModule.Business.HOUSE' already contains a definition for 'hou_file' D:\dev\mojoportal\HouseModule.Business\House.cs 76 23 HouseModule.Business
Error 61 The type 'HouseModule.Business.HOUSE' already contains a definition for 'hou_id' D:\dev\mojoportal\HouseModule.Business\House.cs 56 20 HouseModule.Business
Error 64 The type 'HouseModule.Business.HOUSE' already contains a definition for 'hou_price' D:\dev\mojoportal\HouseModule.Business\House.cs 71 24 HouseModule.Business
Error 62 The type 'HouseModule.Business.HOUSE' already contains a definition for 'hou_title' D:\dev\mojoportal\HouseModule.Business\House.cs 61 23 HouseModule.Business
Error 67 The type 'HouseModule.Business.HOUSE' already contains a definition for 'show_online' D:\dev\mojoportal\HouseModule.Business\House.cs 86 21 HouseModule.Business
Error 70 The type 'HouseModule.Business.HOUSE_TYPE' already contains a definition for 'hot_description' D:\dev\mojoportal\HouseModule.Business\HouseType.cs 63 23 HouseModule.Business
Error 68 The type 'HouseModule.Business.HOUSE_TYPE' already contains a definition for 'hot_id' D:\dev\mojoportal\HouseModule.Business\HouseType.cs 53 20 HouseModule.Business
Error 71 The type 'HouseModule.Business.HOUSE_TYPE' already contains a definition for 'hot_order' D:\dev\mojoportal\HouseModule.Business\HouseType.cs 68 20 HouseModule.Business
Error 69 The type 'HouseModule.Business.HOUSE_TYPE' already contains a definition for 'hot_title' D:\dev\mojoportal\HouseModule.Business\HouseType.cs 58 23 HouseModule.Business
 

Would you have any thoughts on why this happends?

Best regards,

Sietse

 

 

 

 

 

 

 

10/13/2008 2:30:53 AM
Gravatar
Total Posts 8

Re: Generating BusinessClassStub results in "type ... already contrains a definition for .. "

I fixed it by capitalizing every first letter of the Public Proporties in every Class in the BusinessClass.

Just like how it is done in the WebStore and every other module.

 

Could this be a little error in the CodeSmith BusinessClassStubber?

Best regards,

 

 

 

 

 

 

 

10/13/2008 6:46:28 AM
Gravatar
Total Posts 18439

Re: Generating BusinessClassStub results in "type ... already contrains a definition for .. "

Well, it depends on how you look at it. I guess its perhaps a limitation because it does expect certain naming conventions, but you could easily save that codesmith template with a new name and modify it to work in your situation. The issue is that this template is only distinguishing the private property and the public property by case (which is my preference and standard), so the private property is like this:

private DateTime createdUtc = DateTime.UtcNow;

and the public property is like this:

public DateTime CreatedUtc
{
get { return createdUtc; }
set { createdUtc = value; }
}

But if your table column names are already all lower case, the logic in the script which creates the property names doesn't work. The function in the script to get the private name is just lower casing the first letter like this:

public string GetPrivateName(string ColumnName)
{

return ColumnName.Substring(0,1).ToLower() + ColumnName.Substring(1,ColumnName.Length -1);
}

You might need to change that method to prefix the private variable with an underscore _ to make it work with your db naming conventions. I use casing in my db column names, like for the above example my db column is CreatedUtc.

So I guess my db naming conventions are adapted to make it easy to generate clean code easily. I don't use underscores in db column names for example partly because I don't want underscores in the C# property names.

Hope it helps,

Joe

12/26/2009 9:31:06 AM
Gravatar
Total Posts 70

Re: Generating BusinessClassStub results in "type ... already contrains a definition for .. "

Hi Joe !!

Sorry for "taking this back to life" but I'm using PostGre as my DataBase and all my database fields are in lower case (including the ones from "core mojoportal").  I took a look into ...\mojoportal-core\SchemaInstallScripts\pgsql\2.2.7.8.config and noticed that the fields were created this way. Just signing this out if you want to adjust or something :) I'll create my table columns with casing, so this wont bother me  !!

Edit -> Actually gave up from using cases in postgre since other thing's broke with the change. Will use the underscore approach after all ....

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