Why calculated column is created in table?

4 posts, 2 answers
  1. Jose Mejia
    Jose  Mejia avatar
    107 posts
    Member since:
    May 2009

    Posted 08 Oct 2013 Link to this post

    Hi.

    I've sqlite backend and OA version is 2013.2.702.1. I created calculated column and updated db from model and mentioned that
    calcualted column is persisted in table. Why it is so? I supposed that calculated column is transient, as it's name suggests. I mean it has sense only when instance of row in memory. Or it has to be calculated in db, that why it should be persistent?

    My scenario is extend OA entity with additional fields that should be calculated based on persistent, say I've got persisten wkb geo format, but based on this value I want  to have wkt and geojson format. What would you suggest to me in this case: simply extend orm class with my additional fields and custom logic or use some OA mechanisms?

    Thanks in advance.
  2. Answer
    Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 11 Oct 2013 Link to this post

    Hi Jose,

    The transient properties are properties that will not have corresponding columns in the database and one property is transient if its not added in the model. On the other side, the computed columns in the database have corresponding properties in the model which are Persistent Read-Only, because they are calculated in the database and you cannot insert value for them.

    For your case, if you do not want to save the values in the database and then get the calculated ones, the better option is to extend the class with a transient property, where the calculated logic will be executed.

    I hope that helps.

    Regards,
    Boris Georgiev
    Telerik
    OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
  3. DevCraft banner
  4. Jose Mejia
    Jose  Mejia avatar
    107 posts
    Member since:
    May 2009

    Posted 14 Oct 2013 Link to this post

    Ok, thank you!

    Few more question:
    1)why it is not possible to configure transient property via OA model designer (I'm using sqlite as backend)?
    2)related to your links, do you consider Transient attribute obsolete?
    3)am I right that  additional (hand-written) fields in partial class have the same semantics as transient field?
       Or they are different because OA runtime is aware about transient fields (via attributes or another way) and
       hand-written properties aren't in scope of OA runtime?
  5. Answer
    Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 17 Oct 2013 Link to this post

    Hi Jose,

    You can find the answers on your questions below:

    1) Every property which is not in the OpenAccess model can be considered as transient.
    2) If you are not using OpenAccess Clasic Mapping, the transient attribute is obsolete.
    3) When the additional(hand-written) property is not in the OpenAccess model then OpenAccess runtime doesn't know that this property is existing, on the other side, the OpenAccess runtime knows that the transient property is existing, but also knows that the property is not in the mapping.

    I hope that helps.

    Regards,
    Boris Georgiev
    Telerik
    OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
Back to Top