private void DataPortal_Fetch(LineItemCriteria 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_LineItem_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    
                    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.LineItem' using the following criteria: {0}.", criteria));
                    }
                }
            }

            OnFetched();
        }
        private void DataPortal_Fetch(LineItemCriteria criteria)
        {
            bool cancel = false;
            OnFetching(criteria, ref cancel);
            if (cancel) return;

            string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    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.LineItem' using the following criteria: {0}.", criteria));
                    }
                }
            }

            OnFetched();
        }
        /// <summary>
        /// This call to delete is for immediate deletion and doesn't keep track of any entity state.
        /// </summary>
        /// <param name="criteria">The Criteria.</param>
        private void DoDelete(LineItemCriteria criteria)
        {
            bool cancel = false;

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

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_LineItem_Delete]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

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

            OnDeleted();
        }
        private void DataPortal_Fetch(LineItemCriteria criteria)
        {
            bool cancel = false;
            OnFetching(criteria, ref cancel);
            if (cancel) return;

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

                    using(var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if(reader.Read())
                        {
                            do
                            {
                                this.Add(PetShop.Tests.ParameterizedSQL.LineItem.GetLineItem(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
        /// <summary>
        /// Fetch LineItemList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public LineItemList Fetch(LineItemCriteria criteria)
        {
            LineItemList item = (LineItemList)Activator.CreateInstance(typeof(LineItemList), true);

            bool cancel = false;
            OnFetching(criteria, ref cancel);
            if (cancel) return item;

            // Fetch Child objects.
            string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    using(var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new LineItemFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return item;
        }
        /// <summary>
        /// Fetch LineItemList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public LineItemList Fetch(LineItemCriteria criteria)
        {
            LineItemList item = (LineItemList)Activator.CreateInstance(typeof(LineItemList), true);

            bool cancel = false;
            OnFetching(criteria, ref cancel);
            if (cancel) return item;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_LineItem_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    
                    using(var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if(reader.Read())
                        {
                            do
                            {
                                item.Add(new LineItemFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return item;
        }
        private void DataPortal_Fetch(LineItemCriteria 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_LineItem_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    
                    using(var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if(reader.Read())
                        {
                            do
                            {
                                this.Add(PetShop.Tests.StoredProcedures.LineItem.GetLineItem(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
        protected void DoDelete(ref LineItem item)
        {
            // If we're not dirty then don't update the database.
            if (!item.IsDirty)
            {
                return;
            }

            // If we're new then don't call delete.
            if (item.IsNew)
            {
                return;
            }

            var criteria = new LineItemCriteria {
                OrderId = item.OrderId, LineNum = item.LineNum
            };

            DoDelete(criteria);

            MarkNew(item);
        }
        /// <summary>
        /// Fetch LineItem.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public LineItem Fetch(LineItemCriteria criteria)
        {
            bool cancel = false;

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

            LineItem item;

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_LineItem_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            item = Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.LineItem' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
예제 #10
0
        /// <summary>
        /// Fetch LineItemList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public LineItemList Fetch(LineItemCriteria criteria)
        {
            LineItemList item = (LineItemList)Activator.CreateInstance(typeof(LineItemList), true);

            bool cancel = false;

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

            // Fetch Child objects.
            string commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new LineItemFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
예제 #11
0
        /// <summary>
        /// Fetch LineItemList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public LineItemList Fetch(LineItemCriteria criteria)
        {
            LineItemList item = (LineItemList)Activator.CreateInstance(typeof(LineItemList), true);

            bool cancel = false;

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

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_LineItem_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new LineItemFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
        private LineItem Create(LineItemCriteria criteria)
        {
            var item = (LineItem)Activator.CreateInstance(typeof(LineItem), true);

            bool cancel = false;
            OnCreating(ref cancel);
            if (cancel) return item;

            var resource = Fetch(criteria);
            using (BypassPropertyChecks(item))
            {
                item.ItemId = resource.ItemId;
                item.Quantity = resource.Quantity;
                item.UnitPrice = resource.UnitPrice;
            }

            CheckRules(item);
            MarkNew(item);

            OnCreated();

            return item;
        }
        /// <summary>
        /// Fetch LineItem.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public LineItem Fetch(LineItemCriteria criteria)
        {
            bool cancel = false;

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

            LineItem item;
            string   commandText = String.Format("SELECT [OrderId], [LineNum], [ItemId], [Quantity], [UnitPrice] FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            item = Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.LineItem' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="LineItem"/> object. 
 /// </summary>
 /// <param name="criteria"><see cref="LineItemCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(LineItemCriteria criteria, ref bool cancel);
예제 #15
0
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="LineItem"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="LineItemCriteria"/> object containing the criteria of the object to fetch.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param>
 partial void OnFetching(LineItemCriteria criteria, ref bool cancel);
        //[Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Delete(LineItemCriteria criteria, SqlConnection connection)
        {
            bool cancel = false;
            OnDeleting(criteria, ref cancel);
            if (cancel) return;

            using (var command = new SqlCommand("[dbo].[CSLA_LineItem_Delete]", connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

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

            OnDeleted();
        }
        private void DoUpdate(ref LineItem item, bool stopProccessingChildren)
        {
            bool cancel = false;
            OnUpdating(ref cancel);
            if (cancel) return;

            // Don't update if the item isn't dirty.
            if (item.IsDirty)
            {
                if(item.OriginalOrderId != item.OrderId || item.OriginalLineNum != item.LineNum)
                {
                    // Insert new child.
                    var temp = (LineItem)Activator.CreateInstance(typeof(LineItem), true);
                    temp.OrderId = item.OrderId;
                    temp.LineNum = item.LineNum;
                    temp.ItemId = item.ItemId;
                    temp.Quantity = item.Quantity;
                    temp.UnitPrice = item.UnitPrice;
                    temp = temp.Save();
    
                    // Mark child lists as dirty. This code may need to be updated to one-to-one relationships.

                    // Update Children
                    Update_Order_Order_FK__LineItem__OrderI__03317E3D(ref item);
    
                    // Delete the old.
                    var criteria = new LineItemCriteria {OrderId = item.OriginalOrderId, LineNum = item.OriginalLineNum};
                    
                    Delete(criteria);
    
                    // Mark the original as the new one.
                    item.OriginalOrderId = item.OrderId;
                    item.OriginalLineNum = item.LineNum;

                    MarkOld(item);
                    CheckRules(item);
                    OnUpdated();

                    return;
                }

                const string commandText = "UPDATE [dbo].[LineItem] SET [OrderId] = @p_OrderId, [LineNum] = @p_LineNum, [ItemId] = @p_ItemId, [Quantity] = @p_Quantity, [UnitPrice] = @p_UnitPrice WHERE [OrderId] = @p_OrderId AND [LineNum] = @p_LineNum; SELECT [OrderId], [LineNum] FROM [dbo].[LineItem] WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum";
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    using(var command = new SqlCommand(commandText, connection))
                    {
                        command.Parameters.AddWithValue("@p_OriginalOrderId", item.OriginalOrderId);
                command.Parameters.AddWithValue("@p_OrderId", item.OrderId);
                command.Parameters.AddWithValue("@p_OriginalLineNum", item.OriginalLineNum);
                command.Parameters.AddWithValue("@p_LineNum", item.LineNum);
                command.Parameters.AddWithValue("@p_ItemId", item.ItemId);
                command.Parameters.AddWithValue("@p_Quantity", item.Quantity);
                command.Parameters.AddWithValue("@p_UnitPrice", item.UnitPrice);

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

            item.OriginalOrderId = item.OrderId;
            item.OriginalLineNum = item.LineNum;

            MarkOld(item);
            CheckRules(item);

            if(!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Order_Order_FK__LineItem__OrderI__03317E3D(ref item);
            }

            OnUpdated();
        }
        //[Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Delete(LineItemCriteria criteria, SqlConnection connection)
        {
            bool cancel = false;
            OnDeleting(criteria, ref cancel);
            if (cancel) return;

            string commandText = String.Format("DELETE FROM [dbo].[LineItem] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));
            using (var command = new SqlCommand(commandText, connection))
            {
                command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));

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

            OnDeleted();
        }
        protected override void DataPortal_Update()
        {
            bool cancel = false;
            OnUpdating(ref cancel);
            if (cancel) return;

            if(OriginalOrderId != OrderId || OriginalLineNum != LineNum)
            {
                // Insert new child.
                LineItem item = new LineItem {OrderId = OrderId, LineNum = LineNum, ItemId = ItemId, Quantity = Quantity, UnitPrice = UnitPrice};
                
                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 LineItemCriteria {OrderId = OriginalOrderId, LineNum = OriginalLineNum};
                
                DataPortal_Delete(criteria);

                // Mark the original as the new one.
                OriginalOrderId = OrderId;
                OriginalLineNum = LineNum;

                OnUpdated();

                return;
            }

            const string commandText = "UPDATE [dbo].[LineItem] SET [OrderId] = @p_OrderId, [LineNum] = @p_LineNum, [ItemId] = @p_ItemId, [Quantity] = @p_Quantity, [UnitPrice] = @p_UnitPrice WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum; SELECT [OrderId], [LineNum] FROM [dbo].[LineItem] WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum";
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using(var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddWithValue("@p_OriginalOrderId", this.OriginalOrderId);
                command.Parameters.AddWithValue("@p_OrderId", this.OrderId);
                command.Parameters.AddWithValue("@p_OriginalLineNum", this.OriginalLineNum);
                command.Parameters.AddWithValue("@p_LineNum", this.LineNum);
                command.Parameters.AddWithValue("@p_ItemId", this.ItemId);
                command.Parameters.AddWithValue("@p_Quantity", this.Quantity);
                command.Parameters.AddWithValue("@p_UnitPrice", this.UnitPrice);

                    //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(_originalOrderIdProperty, this.OrderId);
                    LoadProperty(_originalLineNumProperty, this.LineNum);
                }

                FieldManager.UpdateChildren(this, connection);
            }

            OnUpdated();
        }
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="LineItem"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="LineItemCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(LineItemCriteria criteria, ref bool cancel);
 public void Delete(LineItemCriteria criteria)
 {
     // Note: this call to delete is for immediate deletion and doesn't keep track of any entity state.
     DoDelete(criteria);
 }
 public void Delete(LineItemCriteria criteria)
 {
     // Note: this call to delete is for immediate deletion and doesn't keep track of any entity state.
     DoDelete(criteria);
 }
        private void DoUpdate(ref LineItem item, bool stopProccessingChildren)
        {
            bool cancel = false;

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

            // Don't update if the item isn't dirty.
            if (item.IsDirty)
            {
                if (item.OriginalOrderId != item.OrderId || item.OriginalLineNum != item.LineNum)
                {
                    // Insert new child.
                    var temp = (LineItem)Activator.CreateInstance(typeof(LineItem), true);
                    temp.OrderId   = item.OrderId;
                    temp.LineNum   = item.LineNum;
                    temp.ItemId    = item.ItemId;
                    temp.Quantity  = item.Quantity;
                    temp.UnitPrice = item.UnitPrice;
                    temp           = temp.Save();

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

                    // Update Children
                    Update_Order_Order_FK__LineItem__OrderI__03317E3D(ref item);

                    // Delete the old.
                    var criteria = new LineItemCriteria {
                        OrderId = item.OriginalOrderId, LineNum = item.OriginalLineNum
                    };

                    Delete(criteria);

                    // Mark the original as the new one.
                    item.OriginalOrderId = item.OrderId;
                    item.OriginalLineNum = item.LineNum;

                    MarkOld(item);
                    CheckRules(item);
                    OnUpdated();

                    return;
                }

                const string commandText = "UPDATE [dbo].[LineItem] SET [OrderId] = @p_OrderId, [LineNum] = @p_LineNum, [ItemId] = @p_ItemId, [Quantity] = @p_Quantity, [UnitPrice] = @p_UnitPrice WHERE [OrderId] = @p_OrderId AND [LineNum] = @p_LineNum; SELECT [OrderId], [LineNum] FROM [dbo].[LineItem] WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum";
                using (var connection = new SqlConnection(ADOHelper.ConnectionString))
                {
                    connection.Open();
                    using (var command = new SqlCommand(commandText, connection))
                    {
                        command.Parameters.AddWithValue("@p_OriginalOrderId", item.OriginalOrderId);
                        command.Parameters.AddWithValue("@p_OrderId", item.OrderId);
                        command.Parameters.AddWithValue("@p_OriginalLineNum", item.OriginalLineNum);
                        command.Parameters.AddWithValue("@p_LineNum", item.LineNum);
                        command.Parameters.AddWithValue("@p_ItemId", item.ItemId);
                        command.Parameters.AddWithValue("@p_Quantity", item.Quantity);
                        command.Parameters.AddWithValue("@p_UnitPrice", item.UnitPrice);

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

            item.OriginalOrderId = item.OrderId;
            item.OriginalLineNum = item.LineNum;

            MarkOld(item);
            CheckRules(item);

            if (!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Order_Order_FK__LineItem__OrderI__03317E3D(ref item);
            }

            OnUpdated();
        }
        protected void DoDelete(ref LineItem item)
        {
            // If we're not dirty then don't update the database.
            if (!item.IsDirty) return;

            // If we're new then don't call delete.
            if (item.IsNew) return;

            var criteria = new LineItemCriteria{OrderId = item.OrderId, LineNum = item.LineNum};
            
            DoDelete(criteria);

            MarkNew(item);
        }
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the <see cref="LineItem"/> object. 
 /// </summary>
 /// <param name="criteria"><see cref="LineItemCriteria"/> object containing the criteria of the object to fetch.</param>
 /// <param name="cancel">Value returned from the method indicating whether the object fetching should proceed.</param>
 partial void OnFetching(LineItemCriteria criteria, ref bool cancel);