// [Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }
            if (OriginalSystemConfigID != SystemConfigID)
            {
                // Insert new child.
                SystemConfig item = new SystemConfig {
                    SystemConfigID = SystemConfigID, Code = Code, Value = Value, IsForUI = IsForUI
                };

                item.DataPortal_Update();

                // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships.

                // Create a new connection.
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    SqlTransaction trans = connection.BeginTransaction();
                    try
                    {
                        UpdateChildren(this, connection, trans);
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw;
                    }

                    //FieldManager.UpdateChildren(this, connection);
                }
                // Delete the old.
                var criteria = new SystemConfigCriteria {
                    SystemConfigID = OriginalSystemConfigID
                };

                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalSystemConfigID = SystemConfigID;
                OnUpdated();

                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                SqlTransaction trans = connection.BeginTransaction();
                try
                {
                    using (var command = new SqlCommand("[dbo].[spCFM_SystemConfig_Update]", connection, trans))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@p_OriginalSystemConfigID", this.OriginalSystemConfigID);
                        command.Parameters.AddWithValue("@p_SystemConfigID", this.SystemConfigID);
                        command.Parameters.AddWithValue("@p_Code", this.Code);
                        command.Parameters.AddWithValue("@p_Value", ADOHelper.NullCheck(this.Value));
                        command.Parameters.AddWithValue("@p_IsForUI", this.IsForUI);
                        //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed.
                        int result = command.ExecuteNonQuery();
                        if (result == 0)
                        {
                            throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute.");
                        }

                        _originalSystemConfigIDProperty = this.SystemConfigID;
                    }
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw;
                }
            }

            OnUpdated();
        }
        /// <summary>
        /// Creates a new object of type <see cref="SystemConfig"/>.
        /// </summary>
        /// <returns>Returns a newly instantiated collection of type <see cref="SystemConfig"/>.</returns>
        public static SystemConfig NewSystemConfig()
        {
            SystemConfig obj = new SystemConfig();

            return(obj);
        }
 protected void UpdateChildren(SystemConfig parent, SqlConnection connection, SqlTransaction trans)
 {
 }