update database values urgent

Thread is closed for posting
2 posts, 0 answers
  1. Derya Altuntas
    Derya Altuntas avatar
    5 posts
    Member since:
    Nov 2009

    Posted 10 Nov 2009 Link to this post

    Platform configuration is a database class that has relationship with SensorRadar class.Combobox is loaded from SensorRadar Table.
    I want to add new Sensor Radar to Platform Configuration if it doesn't.And change Sensor Radar with selected combobox Sensor Radar if it has .But Platform configuration object_id column doesn't change.It refers to SensorRadar class Id.Please help.How can update.

    bool isPlatformHasRadarSensor = false;
                    foreach (PlatformConfiguration platformConfiguration in m_originalMunitionList)
                        if (platformConfiguration.ConfigurationItemType == Constants.CONFIGURATION_ITEM_TYPE_SENSOR_RADAR)
                            platformConfiguration.SensorRadar = ((SensorRadar)m_cmbbx_loadAirRadar.SelectedItem);
                            isPlatformHasRadarSensor = true;
                    if (!isPlatformHasRadarSensor)
                        IQuery query = m_scope.GetSqlQuery("sp_ins_Pltfrm_Conf ?,?,?,?",


                                        "GUID object_ID, GUID platform_ID, INTEGER configuration_item_type, INTEGER quantity");

                        IQueryResult a = query.Execute(new object[] { ((SensorRadar)m_cmbbx_loadAirRadar.SelectedItem).Id, selectedAirPlatform.Id, Constants.CONFIGURATION_ITEM_TYPE_SENSOR_RADAR, null });
                        int count = a.Count;
  2. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 11 Nov 2009 Link to this post

    Hi Derya Altuntas,

    In order to work with persistent data an object scope is required. The object scope provides a working area for all database objects. I assume that the m_originalMunitionList is a list of persistent objects, retrieved by executing a query against certain IObjectScope instance. You can use the following code to retrieve that IObjectScope:
    IObjectScope scope = Database.GetContext(m_originalMunitionList) as IObjectScope;

    Before you can perform any operations on the persistent objects, you need to start a transaction. This is done with the ITransaction.Begin() method. Any modifications made to an object after beginning the transaction can be stored in the database by calling ITransaction.Commit(). Performing the update operation inside the foreach loop would look like this:

    if (platformConfiguration.ConfigurationItemType == Constants.CONFIGURATION_ITEM_TYPE_SENSOR_RADAR)
        platformConfiguration.SensorRadar = ((SensorRadar)m_cmbbx_loadAirRadar.SelectedItem);
        isPlatformHasRadarSensor = true;
    You can begin and commit the transaction outside of the loop as well.

    Additional useful information about the CRUD operations and Telerik OpenAccess ORM could be found in this article. Hope that helps.

    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top