rory
rory

Reputation: 1438

Kentico 11: Prevent Page Type Code Generation from removing class name prefix in fields

I have a Page Type with a code My.Product and I have a field called ProductType.

I used the Kentico code generator tool to get a ProductType.Generated.cs class but when I call the following code I see the field ProductType has the 'Product' class name prefix removed:

using (var product= new Product())
{
    return product.Fields.Properties;
}

and when I check the ProductType.Generated.cs I see that the class name prefix is indeed removed. Is there any way I can configure this not to? Or do I need to rename all my fields?

Upvotes: 0

Views: 68

Answers (1)

Mcbeev
Mcbeev

Reputation: 1529

When I do your same example, I get a

Product.generated.cs

not ProductType. It should use the object name for the file, not the property name.

Kentico MVC Page Type Custom Product

Is is your codename of the object truly My.Product ? Or is the namespace something like Custom and then My.Product in the codename (second field after the period)

Kentico Page Type codename

Either way you will most likely have to rename / edit the generated code files if you want it to be something different than what Kentico generates. It is only based off of the name in the UI. Which is not really recommended per the Kentico docs on the topic.

Also make sure you are on hotfix 24 or higher of version 11. As there are some known issues that were fixed in 24 for page code generation.

Upvotes: 1

Related Questions