Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Harsheet 71 posts 302 karma points
    Nov 07, 2016 @ 22:20
    Harsheet
    0

    Models Builder - the property name and the class name cannot be same

    I already have a project running live and all the mapping is done traditionally. Now I want to use ModelsBuilder but the problem is that I have some documentTypes that have same name as the property name and I am getting this error -

    CSharp does not support using the same name for the property with alias "adConfigs" (one of the doc Types in my case). Consider using an attribute to assign a different name to the property.

  • Jonathan Richards 288 posts 1742 karma points MVP
    Nov 08, 2016 @ 17:19
    Jonathan Richards
    100

    Hi

    Yes it is true that C# will not allow you to have a class and a property share the same name. This has been a restriction of c# for the last 15 years, and AFAIK isn't about to change anytime soon. I could state, that this rule is there to signify to the complier which methods are constructors, but I suspect, if you gave this a little bit of thought you might have already known this.

    I have, for comic effects, instead read your post as a statement, and yes, you are quite right "the property name and the class name cannot be same". I wish to congratulate you on testing this functionality, as everything is working as expected and you haven't broken the c# compiler.

    Cheers

    ps. If your finding my post way too sarcastic, it really is, so that you understand, there is nothing you can do, except change the aliases if you wish to use modelsbuilder and this isn't because of a bug in modelsbuilder or Umbraco but because of a fundamental fact about C#.

  • Harsheet 71 posts 302 karma points
    Nov 08, 2016 @ 21:43
    Harsheet
    0

    Hi,

    Yes this is true and thanks for your reply.

    I have fixed this using an attribute over the class name or we can do this by changing the alias in the xml as well.

    My problem was that I could not change the alias directly as my site is already running live.

    But its fixed now.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft