Copied to clipboard

Flag this post as spam?

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

  • nojaf 91 posts 300 karma points
    Nov 30, 2013 @ 14:14

    Code gen general


    I'm look for a tool that scans my DataTypes and creates c# classes of it.

    Now I'm doing this by hand and it's taking way to much time.

    How can I get CodeGen up and running on a 6.12 installation.

    Also I have no knowledge what uSync is.



  • nojaf 91 posts 300 karma points
    Dec 02, 2013 @ 12:22

    Ok I've managed to install the Codegen package. And I got everything running. But unfortunately the generated code doesn't fit my needs.

    I was hoping that the properties would look like:


    public WhatEver SomeName{
              return Convert.ToWhatEver(_iContent.Get("TheAlias"));
              _iContent.SetValue("TheAlias", value);

    I really need a Setter to all the classes. And what I also miss is a list of Child items if so defined.

    Don't get me wrong, the package is amazing but it's unusable for the project I'm building.

  • Lars-Erik Aabech 349 posts 1100 karma points MVP 7x c-trib
    Dec 02, 2013 @ 14:52
    Lars-Erik Aabech

    Good to hear that you got it running.
    Alas, it's a bit tricky to get everything right for now.
    The "real" typed model support in Umbraco isn't in the core for 6.1.x, so you'll have to make your own default controller etc.
    If you're brave enough to run on 6.2 nightly, you can use the "WhileWaitingForSixTwo" project from my 7.0.modelsupport branch.
    That will give you the models as IPublishedContent implementations, and they have .Children of the typed models. You can for instance do:

    @inherits UmbracoViewPage<Page>
    @foreach(var post in Model.Children.OfType<Post>())

    If you need setters, you can create your own property body generator class and override the factory used by codegen. Basically you can have whatever code you want if you do the (small amount of) work needed.


    Here's the code that currently generates the property body:

    If it's too much work for you, stay tuned for coming Umbraco releases for full-fledged support. :)
    (6.2+, 7.?)

Please Sign in or register to post replies

Write your reply to: