Reverse mapping, adding new fields

5 posts, 1 answers
  1. Robert Lautenbach
    Robert Lautenbach avatar
    18 posts
    Member since:
    Dec 2009

    Posted 12 May 2010 Link to this post

    I've been using reverse mapping as I develop a new system. During development I have been adding fields to tables and running merges to get the new data in my persisted objects. I noticed pretty quickly that the merge routine does not touch the top level generated partial class files.

    Is there any way to force generation of a top level partial class file? Is there anywhere in the reverse mapping tool I can go to copy the new top level partial class property code?

    I completely understand leaving this file untouched to avoid disrupting any custom changes/additions. It makes perfect sense. But there has to be some way to insert new field properties into these files as new fields are merged in. 

    It's frustrating to run a merge and then have to go into individual class files and add properties. Whenever I add a few fields of varying data types, including foreign key fields that end up as lists, I have to hand code a bunch of properties that I don't otherwise customize. This should be automated somehow or at the very least there should be somewhere I can go to copy the new code and paste it into my partial classes.

    Thanks!
  2. Robert Lautenbach
    Robert Lautenbach avatar
    18 posts
    Member since:
    Dec 2009

    Posted 12 May 2010 Link to this post

    Just to clarify a bit on my one requested solution --

    When I view "Source Code and Mapping for the complete class" in the Reverse Mapping window I see the private variable declarations and the xml mapping info. Having a similar panel to copy the public property declarations would be a big help. That said, some kind of automation for the public properties would be ideal.


  3. DevCraft banner
  4. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 13 May 2010 Link to this post

    Hello Robert Lautenbach,

    The behavior you are observing is actually by design. The Reverse mapping wizard by default generates two partial classes for each of your tables. One is [name of class].cs that holds the properties definitions and one is [name of class].Telerik.OpenAccess.cs that holds the private fields definitions. During regeneration of the classes only the one holding the private fields gets regenerated. This is done because by default we assume that the user might have some custom code implemented in his properties and we are intentionally not overriding it. If you look at the end of the file that contains your private fields you will find the code for the all the properties as commented out. You can manually copy it over your property class if you don't have any property logic that you will erase. In order to avoid the manual copy you should disable the generation of partial classes. This will result in generating your fields and properties in one and the same file, thus overriding it with the complete definition after each merge. In order to turn the partial generation off you sholud follow the steps provided in this topic.

    Kind regards,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Robert Lautenbach
    Robert Lautenbach avatar
    18 posts
    Member since:
    Dec 2009

    Posted 13 May 2010 Link to this post

    I don't seem to have the commented out public properties in my partial class with the private properties. I am running the 2010 Q1 release.
  6. Answer
    PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 17 May 2010 Link to this post

    Hello Robert Lautenbach,

    The commented code is available only for C#. If you are using VB.NET I am afraid that you won't be able to take advantage of that feature and the only way for you not to do anything by hand would be to disable the partial class generation.
    I am sorry for any inconvenience caused.

    Regards,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
DevCraft banner