Identify Computed Columns

6 posts, 0 answers
  1. Garry
    Garry avatar
    205 posts
    Member since:
    Nov 2010

    Posted 08 Aug 2010 Link to this post

    I have a need to identify computed columns, but I haven't been able to figure out how. Below is what I have so far and I have set the Kind property on the column to Calculated, but I can't find that property anywhere on the column at runtime. It doesn't appear to even be in the MetaDataProperties collection. How can I find these columns?

    Thanks!

    //determine if this scope already exists on the server and if not go ahead and provision
                            foreach (MetaTable table in scope.OpenAccessMetaData.Tables)
                            {
                                Collection<string> syncColumns = new Collection<string>();
                                foreach (MetaColumn column in table.Columns)
                                {
                                    if (column.Name != "DisguisedSSN")
                                    {
                                        syncColumns.Add(column.Name);
                                    }
                                }
                                //add the approrpiate tables to this scope
                                scope.ScopeDescription.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable(table.Name, syncColumns, (System.Data.SqlClient.SqlConnection)remoteProvider.Connection));
                            }
  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 10 Aug 2010 Link to this post

    Hi Garry Clark,

    I suggest you to set the Kind property to "PersistentReadOnly" so that this column is being only read by the server which calculates it("Calculated" is bit different option where one should specify his own SQL for calculating the value but, that is not implemented yet). After you do that you should go for the MetaColumn.DataAccessKind property which returns a value from the DataAccessKind enumeration. 

    foreach (MetaTable table in scope.OpenAccessMetaData.Tables)
    {
        ...
        foreach (MetaColumn column in table.Columns)
        {
            ...
            if (column.DataAccessKind == DataAcccessKind.ReadOnly)
            {
                //do something
            }
            ...
        }
        ...
    }

    Hope that helps. If any other questions arise please contact us back.


    Sincerely yours,
    Damyan Bogoev
    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
  3. DevCraft banner
  4. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 01 Jul 2011 Link to this post

    Hi Damyan,

    Do you mean that computed/calculated fields in the database are not automatically mapped as DataAcccessKind.ReadOnly
    ? So, every time I do an 'update from database' I have to set this parameters...?

    Erik
  5. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 06 Jul 2011 Link to this post

    Hello Erik,

    Yes, the calculated columns are not mapped automatically to read only properties and you should do that explicitly.
    I am sorry for the inconvenience caused.

    Kind regards,
    Damyan Bogoev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. Ian
    Ian avatar
    26 posts
    Member since:
    Jun 2012

    Posted 26 Nov 2011 Link to this post

    Hi,
    I'm just getting up to speed on the Telerik ORM.  Is the automatic flagging of database calculated columns (in my case I use SQL Server) going to be improved upon in future?  Just curious.
    Thanks,
    Ian
  7. Ady
    Admin
    Ady avatar
    588 posts

    Posted 29 Nov 2011 Link to this post

    Hello Vernon,

    Yes, this is very much on the list of features we would like to have and we would be implementing this. I cannot give you an exact timeframe at the moment , but it will definitely be done.

    Kind regards,
    Ady
    the Telerik team

    Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Back to Top
DevCraft banner