How to reorder properties in generated class file

12 posts, 0 answers
  1. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 18 Aug 2014 Link to this post

    Hello,

    how can I influence the order of properties when generating a class using the Visual Designer?

    The properties should appear in the same order as the tables or views in the database.

    I'm using EPPlus to export the data into excel. The LoadFromCollection() method provided by the EEPlus library is unfortunately depended on the property order of the underlying object. Which causes a ridiculous column order in the exported excel sheets.

    Thank you
  2. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 20 Aug 2014 Link to this post

    Hi Joel,

    Thank you for contacting us.

    Generally in the code file, the persistent classes generated by Telerik Data Access have their properties ordered in the same order as the respective columns in the database table.

    Note however that the order of the properties displayed in the Visual Designer is alphabetical and therefore often different than the actual order of the properties in the code of the class. The order of the properties in the Visual Designer does not impact the order of the properties in the code of the class. This could have potentially left you with the wrong impression regarding the property order.

    With this in mind we would recommend you verify whether the property order in the code of the class indeed differs than the column order in the respective tables.

    Additionally if you are interested in functionality that allows you to control the property order in the code of the classes through the visual designer, please do not hesitate to post a feature request at our public Ideas and Feedback portal. Voting for the request will help us prioritize its potential implementation.

    I hope this helps. Should you have additional questions or need help, feel free to post at our forums again.

    Regards,
    Kristian Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 20 Aug 2014 in reply to Kristian Nikolov Link to this post

    Kristian Nikolov said:

    Generally in the code file, the persistent classes generated by Telerik Data Access have their properties ordered in the same order as the respective columns in the database table.
     


    Is this statement also valid for views? The persistent view classes have their properties ordered alphabetical descending.
  5. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 22 Aug 2014 Link to this post

    Hi Joel,

    Yes the statement is valid also for views. The properties in the generated class are ordered in the same order as the respective columns in the database view.

    If any other questions arise, do not hesitate to contact us again,

    Regards,
    Boris Georgiev
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  6. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 25 Aug 2014 in reply to Boris Georgiev Link to this post



    I’m afraid I found a bug in OpenAccess
    regarding the property order in the generated classes.

    Steps to reproduce:

    0)            Perquisites:
    I’m using VS 2013, .Net 4.5, SQL Server 2012 and DataAccess Build 2014.2.711

    1)            Create
    a new (wpf) project

    2)            Add
    a “Telerik Data Access Domain Model” to the project

    a.            Make
    sure you check the “Generate Multiple Files” option

    3)            Add
    a View and Assign a Key

    4)            Save
    the Model and check the generated class file

    a.            The
    properties in the generated class are ordered in the same order as the
    respective columns in the database view -> SUCCESS!

    5)            Let’s
    stress this a bit…

    6)            Delete
    the View from the Model

    a.            Select
    the visual representation of the model, right click and delete

    b.            Open
    the “Model Schema Explorer” navigate to the View, right click and hit “remove
    view”

    c.             Save
    the Model

    d.            Delete
    the respective generated class file (*.generated.cs)

    7)            Go
    back into “the Telerik Data Access Domain Model”, right click and select
    “Update from Database”

    8)            Add
    a (arbitrary) View and Assign a Key

    9)            Save
    the Model and check the generated class file

    a.            The
    properties in the generated view class are ordered alphabetical descending
    -> BUG!?

    Thank you for looking into this.

    Regards,

    Joel

     

  7. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 25 Aug 2014 in reply to Tim Link to this post

    somehow the formatting got lost, sorry about that.

    I also added a bug report about this issue: http://feedback.telerik.com/Project/114/Feedback/Details/136394-bug-report-property-order-in-the-generated-classes
  8. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 27 Aug 2014 Link to this post

    Hello Joel,

    Thank you for getting back to us.

    Indeed this is a bug on our side. It appears that during update from database the metadata for the view is constructed in a different manner. This leads to generating the properties in a different order. The issue is logged in our system for prioritization and scheduling. Please accept our apologies for the caused inconvenience.

    A workaround for this issue would be to create a new domain class in the designer and map it to the view manually:
    1. From the Visual Designer, delete the initial class for the view, but leave the view in the Model Schema Explorer.
    2. In the Visual Designer define a new class. Add properties in it in the order in which you wish them to be generated in the code. When creating a new class, the properties are generated in the order they are added to it.
    3. Save the model and build the solution.
    4. Select the newly created class from the designer.
    5. Open the Mapping Details Editor and select the tables tab.
    6. From the Mapped to  dropdown select the respective view.
    7. From the grid map each column of the view to the respective property of the class.
    8. Afterwards select the Identity member for the new class.
    You should now be able to use the new class to query your view.

    I hope this helps. Should you have further questions, feel free to post at our forums again.

    Regards,
    Kristian Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  9. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 28 Aug 2014 in reply to Kristian Nikolov Link to this post

    Can you already give me an ETA for a fix?
  10. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 02 Sep 2014 Link to this post

    Hello Joel,

    We will make sure to contact you in this thread as soon as the bug has been scheduled and/or fixed. However, please note that currently we do not expect this behavior to be addressed in the nearing releases of Telerik Data Access. With this in mind we would recommend using the workaround mentioned in my previous answer to this ticket.

    I hope this helps. Feel free to get back to us in case you have additional questions.

    Regards,
    Kristian Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  11. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 14 Oct 2014 in reply to Kristian Nikolov Link to this post

    The workaround provided by you is not suitable for large views therefore I'm still waiting for a fix.

    For me and my company this is still an urgent issue. In fact, we won't renew our subscription until this is fixed.


  12. Tim
    Tim avatar
    18 posts
    Member since:
    Jul 2013

    Posted 14 Oct 2014 in reply to Kristian Nikolov Link to this post

    The workaround provided by you is not suitable for large views therefore I'm still waiting for a fix.

    For me and my company this is still an urgent issue. In fact, we won't renew our subscription until this is fixed.
  13. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 17 Oct 2014 Link to this post

    Hi Joel,

    We are sorry to see that the proposed workaround is not applicable for your scenario. Unfortunately there is no other approach that we can suggest to you in order to address the issue.

    Regarding the bug in question, we have investigated it and as it turns out implementing a fix for it would be a very complex task that would have a negative impact on multiple aspects of Telerik Data Access. Therefore, our short term plans do not include addressing this issue. Please do note that this may change in which case we will inform you in this thread when the bug is scheduled or fixed.

    I hope this helps. Do not hesitate to post in our forums again should you have additional questions.

    Regards,
    Kristian Nikolov
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top
DevCraft banner