0

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?

rory
  • 1,490
  • 3
  • 22
  • 50

1 Answers1

1

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.

Mcbeev
  • 1,519
  • 9
  • 9
  • @Mcveev the issue isn't the class name itself. That generates as expected. The issue is if you have a field name prefixed with the class name. If you have a field name called ProductType it will generate a field called 'Type' instead of 'ProductType' – rory May 18 '20 at 07:17
  • 1
    It's not OOTB functionally to do as your stating @rory. Mcbeev us correct in his statements. I'd suggest trying a basic page type with names other than your suggesting and 2 fields and see if you get the same results – Brenden Kehren May 19 '20 at 06:32
  • @BrendenKehren I've decided to rename my fields to not have the classname as a prefix. However, Kentico pages all have the field [ClassName]ID which gives me a field of just 'ID' in the generated code so that needs to be dealt with manually. – rory May 19 '20 at 09:42