StrataFrame Forum

Member name conflict with Type name.

http://forum.strataframe.net/Topic1609.aspx

By Jason Stevenson - 6/21/2006

I am wrapping up my first project with Strataframe.  I am now remapping to the production database, and have discovered what appears to be a bug...

I have a SQL databse with a Table named: DealerType.  That table contains a column named: DealerType.  So the generated class wont compile because the Member name cannot be the same as the Containing Type name.  Here are some snippets of generated code:

namespace DealerLocatorAdmin

{

public partial class DealerType : MicroFour.StrataFrame.Business.BusinessLayer

{

/// <summary>

/// DealerType

/// </summary>

/// <remarks></remarks>

[Browsable(false),

BusinessFieldDisplayInEditor(),

Description("DealerType"),

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

public System.String DealerType

{

get

{

return (System.String)this.CurrentRow["DealerType"];

}

set

{

this.CurrentRow["DealerType"] = value;

}

}

Any ideas on how to work around this?

By StrataFrame Team - 6/21/2006

Jason,

The problem is with C# only.   You cannot create a member that has the same name as the containing type because only the constructors are allowed to have the same name as the containing type.  What you'll need to do is:

1) Copy the DealerType property from the .designer.cs file. 

2) Then go to the Business Object Mapper and customize the DealerType field on the business object. 

3) Choose the "Use Custom Code" option and paste the copied code into the "Custom Code" window at the bottom. 

4) Then, simply change the name of the property from "DealerType" to "DealerTypeName" or "DealerType2" or something that is unique from the name of the class. 

Or, you could simply rename your business object from "DealerType" to "DealerTypeBO" or "DealerTypeBizObj" or something that will allow the object to continue to use the property name of DealerType.

Those are about your only options.  Hope that helps Smile

By Jason Stevenson - 6/21/2006

Duh!  Thanks dude... I should have thought of renaming the BO...

Jason