コード例 #1
0
        protected override void DataPortal_Execute()
        {
            string commandText = string.Format("SELECT COUNT(1) FROM {0} {1}", Criteria.TableFullName, ADOHelper.BuildWhereStatement(Criteria.StateBag));

            using (SqlConnection connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(Criteria.StateBag));
                    Result = (int)command.ExecuteScalar() > 0;
                }
            }
        }
コード例 #2
0
        private void Child_Insert(Product product, Supplier supplier, SqlConnection connection)
        {
            bool cancel = false;

            OnChildInserting(product, supplier, connection, ref cancel);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[CSLA_Item_Insert]", connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                command.Parameters.AddWithValue("@p_ProductId", product != null ? product.ProductId : this.ProductId);
                command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(this.ListPrice));
                command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(this.UnitCost));
                command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(supplier != null ? supplier.SuppId : this.Supplier));
                command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(this.Status));
                command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));

                command.ExecuteNonQuery();

                // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query.
                if (product != null && product.ProductId != this.ProductId)
                {
                    LoadProperty(_productIdProperty, product.ProductId);
                }

                // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query.
                if (supplier != null && supplier.SuppId != this.Supplier)
                {
                    LoadProperty(_supplierProperty, supplier.SuppId);
                }

                // Update the original non-identity primary key value.
                LoadProperty(_originalItemIdProperty, this.ItemId);
            }

            // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild).
            // TODO: Please override OnChildInserted() and insert this child manually.
            // FieldManager.UpdateChildren(this, connection);

            OnChildInserted();
        }
コード例 #3
0
        private void Child_Update(Category category, SqlConnection connection)
        {
            bool cancel = false;

            OnChildUpdating(category, connection, ref cancel);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[CSLA_Product_Update]", connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_OriginalProductId", this.OriginalProductId);
                command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                command.Parameters.AddWithValue("@p_CategoryId", category != null ? category.CategoryId : this.CategoryId);
                command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                command.Parameters.AddWithValue("@p_Descn", ADOHelper.NullCheck(this.Description));
                command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));

                //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.");
                }

                // Update non-identity primary key value.
                LoadProperty(_productIdProperty, (System.String)command.Parameters["@p_ProductId"].Value);

                // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query.
                if (category != null && category.CategoryId != this.CategoryId)
                {
                    LoadProperty(_categoryIdProperty, category.CategoryId);
                }

                // Update non-identity primary key value.
                LoadProperty(_originalProductIdProperty, this.ProductId);
            }

            FieldManager.UpdateChildren(this, null, connection);

            OnChildUpdated();
        }
コード例 #4
0
        private void Child_Update(SqlConnection connection)
        {
            bool cancel = false;

            OnChildUpdating(connection, ref cancel);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[CSLA_Item_Update]", connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_OriginalItemId", this.OriginalItemId);
                command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(this.ListPrice));
                command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(this.UnitCost));
                command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(this.Supplier));
                command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(this.Status));
                command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));

                //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.");
                }

                // Update non-identity primary key value.
                LoadProperty(_itemIdProperty, (System.String)command.Parameters["@p_ItemId"].Value);

                // Update non-identity primary key value.
                LoadProperty(_originalItemIdProperty, this.ItemId);
            }

            FieldManager.UpdateChildren(this, connection);

            OnChildUpdated();
        }
コード例 #5
0
        private void Child_Fetch(SupplierCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_Addr1HasValue", criteria.Addr1HasValue);
                    command.Parameters.AddWithValue("@p_Addr2HasValue", criteria.Addr2HasValue);
                    command.Parameters.AddWithValue("@p_CityHasValue", criteria.CityHasValue);
                    command.Parameters.AddWithValue("@p_StateHasValue", criteria.StateHasValue);
                    command.Parameters.AddWithValue("@p_ZipHasValue", criteria.ZipHasValue);
                    command.Parameters.AddWithValue("@p_PhoneHasValue", criteria.PhoneHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                this.Add(PetShop.Tests.StoredProcedures.Supplier.GetSupplier(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
コード例 #6
0
        private void Child_Fetch(ItemCriteria criteria)
        {
            bool cancel = false;

            OnChildFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Item_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_ListPriceHasValue", criteria.ListPriceHasValue);
                    command.Parameters.AddWithValue("@p_UnitCostHasValue", criteria.UnitCostHasValue);
                    command.Parameters.AddWithValue("@p_SupplierHasValue", criteria.SupplierHasValue);
                    command.Parameters.AddWithValue("@p_StatusHasValue", criteria.StatusHasValue);
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_ImageHasValue", criteria.ImageHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Item' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnChildFetched();


            MarkAsChild();
        }
コード例 #7
0
        private void Child_Insert(Category category, SqlConnection connection)
        {
            bool cancel = false;

            OnChildInserting(category, connection, ref cancel);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[CSLA_Product_Insert]", connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                command.Parameters.AddWithValue("@p_CategoryId", category != null ? category.CategoryId : this.CategoryId);
                command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                command.Parameters.AddWithValue("@p_Descn", ADOHelper.NullCheck(this.Description));
                command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));

                command.ExecuteNonQuery();

                // Update foreign keys values. This code will update the values passed in from the parent only if no errors occurred after executing the query.
                if (category != null && category.CategoryId != this.CategoryId)
                {
                    LoadProperty(_categoryIdProperty, category.CategoryId);
                }

                // Update the original non-identity primary key value.
                LoadProperty(_originalProductIdProperty, this.ProductId);
            }

            // A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild).
            // TODO: Please override OnChildInserted() and insert this child manually.
            // FieldManager.UpdateChildren(this, null, connection);

            OnChildInserted();
        }
コード例 #8
0
        protected void DataPortal_Fetch(SupplierCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_Addr1HasValue", criteria.Addr1HasValue);
                    command.Parameters.AddWithValue("@p_Addr2HasValue", criteria.Addr2HasValue);
                    command.Parameters.AddWithValue("@p_CityHasValue", criteria.CityHasValue);
                    command.Parameters.AddWithValue("@p_StateHasValue", criteria.StateHasValue);
                    command.Parameters.AddWithValue("@p_ZipHasValue", criteria.ZipHasValue);
                    command.Parameters.AddWithValue("@p_PhoneHasValue", criteria.PhoneHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Supplier' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnFetched();
        }
コード例 #9
0
        protected override void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Insert]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_SuppId", this.SuppId);
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                    command.Parameters.AddWithValue("@p_Status", this.Status);
                    command.Parameters.AddWithValue("@p_Addr1", ADOHelper.NullCheck(this.Addr1));
                    command.Parameters.AddWithValue("@p_Addr2", ADOHelper.NullCheck(this.Addr2));
                    command.Parameters.AddWithValue("@p_City", ADOHelper.NullCheck(this.City));
                    command.Parameters.AddWithValue("@p_State", ADOHelper.NullCheck(this.State));
                    command.Parameters.AddWithValue("@p_Zip", ADOHelper.NullCheck(this.Zip));
                    command.Parameters.AddWithValue("@p_Phone", ADOHelper.NullCheck(this.Phone));
                    command.ExecuteNonQuery();

                    using (BypassPropertyChecks)
                    {
                    }
                }

                LoadProperty(_originalSuppIdProperty, this.SuppId);

                FieldManager.UpdateChildren(this, connection);
            }

            OnInserted();
        }
コード例 #10
0
        private void DataPortal_Fetch(CategoryCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Category_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_DescnHasValue", criteria.DescriptionHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                this.Add(PetShop.Tests.StoredProcedures.Category.GetCategory(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
コード例 #11
0
        protected override void DataPortal_Insert()
        {
            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Item_Insert]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                    command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                    command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(this.ListPrice));
                    command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(this.UnitCost));
                    command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(this.Supplier));
                    command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(this.Status));
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                    command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));
                    command.ExecuteNonQuery();

                    using (BypassPropertyChecks)
                    {
                    }
                }

                LoadProperty(_originalItemIdProperty, this.ItemId);

                FieldManager.UpdateChildren(this, connection);
            }

            OnInserted();
        }
コード例 #12
0
        private void DataPortal_Fetch(ProductCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Product_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_DescnHasValue", criteria.DescriptionHasValue);
                    command.Parameters.AddWithValue("@p_ImageHasValue", criteria.ImageHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Product' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnFetched();
        }
コード例 #13
0
        private void Child_Insert(SqlConnection connection)
        {
            bool cancel = false;

            OnChildInserting(connection, ref cancel);
            if (cancel)
            {
                return;
            }

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            using (var command = new SqlCommand("[dbo].[CSLA_Item_Insert]", connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(this.ListPrice));
                command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(this.UnitCost));
                command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(this.Supplier));
                command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(this.Status));
                command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));

                command.ExecuteNonQuery();

                // Update the original non-identity primary key value.
                LoadProperty(_originalItemIdProperty, this.ItemId);
            }

            FieldManager.UpdateChildren(this, connection);

            OnChildInserted();
        }
コード例 #14
0
        protected override void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }

            if (OriginalSuppId != SuppId)
            {
                // Insert new child.
                Supplier item = new Supplier {
                    SuppId = SuppId, Name = Name, Status = Status, Addr1 = Addr1, Addr2 = Addr2, City = City, State = State, Zip = Zip, Phone = Phone
                };

                item = item.Save();

                // Mark editable child lists as dirty. This code may need to be updated to one-to-one relationships.
                foreach (Item itemToUpdate in Items)
                {
                    itemToUpdate.Supplier = SuppId;
                }

                // Create a new connection.
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    FieldManager.UpdateChildren(this, connection);
                }

                // Delete the old.
                var criteria = new SupplierCriteria {
                    SuppId = OriginalSuppId
                };

                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalSuppId = SuppId;
                OnUpdated();

                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Update]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_OriginalSuppId", this.OriginalSuppId);
                    command.Parameters.AddWithValue("@p_SuppId", this.SuppId);
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                    command.Parameters.AddWithValue("@p_Status", this.Status);
                    command.Parameters.AddWithValue("@p_Addr1", ADOHelper.NullCheck(this.Addr1));
                    command.Parameters.AddWithValue("@p_Addr2", ADOHelper.NullCheck(this.Addr2));
                    command.Parameters.AddWithValue("@p_City", ADOHelper.NullCheck(this.City));
                    command.Parameters.AddWithValue("@p_State", ADOHelper.NullCheck(this.State));
                    command.Parameters.AddWithValue("@p_Zip", ADOHelper.NullCheck(this.Zip));
                    command.Parameters.AddWithValue("@p_Phone", ADOHelper.NullCheck(this.Phone));
                    //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.");
                    }

                    LoadProperty(_originalSuppIdProperty, this.SuppId);
                }

                FieldManager.UpdateChildren(this, connection);
            }

            OnUpdated();
        }
コード例 #15
0
        protected override void DataPortal_Update()
        {
            bool cancel = false;

            OnUpdating(ref cancel);
            if (cancel)
            {
                return;
            }

            if (OriginalItemId != ItemId)
            {
                // Insert new child.
                Item item = new Item {
                    ItemId = ItemId, ProductId = ProductId, Status = Status, Name = Name, Image = Image
                };
                if (ListPrice.HasValue)
                {
                    item.ListPrice = ListPrice.Value;
                }
                if (UnitCost.HasValue)
                {
                    item.UnitCost = UnitCost.Value;
                }
                if (Supplier.HasValue)
                {
                    item.Supplier = Supplier.Value;
                }
                item = item.Save();

                // 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();
                    FieldManager.UpdateChildren(this, connection);
                }

                // Delete the old.
                var criteria = new ItemCriteria {
                    ItemId = OriginalItemId
                };

                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalItemId = ItemId;
                OnUpdated();

                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Item_Update]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_OriginalItemId", this.OriginalItemId);
                    command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                    command.Parameters.AddWithValue("@p_ProductId", this.ProductId);
                    command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(this.ListPrice));
                    command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(this.UnitCost));
                    command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(this.Supplier));
                    command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(this.Status));
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(this.Name));
                    command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(this.Image));
                    //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.");
                    }

                    LoadProperty(_originalItemIdProperty, this.ItemId);
                }

                FieldManager.UpdateChildren(this, connection);
            }

            OnUpdated();
        }