예제 #1
0
        protected void DataPortal_Fetch(OrderStatusCriteria criteria)
        {
            bool cancel = false;

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

            string commandText = String.Format("SELECT [OrderId], [LineNum], [Timestamp], [Status] FROM [dbo].[OrderStatus] {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.OrderStatus' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnFetched();
        }
예제 #2
0
        protected void DataPortal_Delete(OrderStatusCriteria criteria)
        {
            bool cancel = false;

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

            string commandText = String.Format("DELETE FROM [dbo].[OrderStatus] {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));

                    //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();
        }
예제 #3
0
        /// <summary>
        /// Returns a <see cref="OrderStatus"/> object of the specified criteria.
        /// </summary>
        /// <param name="orderId">No additional detail available.</param>
        /// <returns>A <see cref="OrderStatus"/> object of the specified criteria.</returns>
        public static OrderStatus GetByOrderId(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(DataPortal.Fetch <OrderStatus>(criteria));
        }
예제 #4
0
        /// <summary>
        /// Returns a <see cref="OrderStatusList"/> object of the specified criteria.
        /// </summary>
        /// <param name="orderId">No additional detail available.</param>
        /// <returns>A <see cref="OrderStatusList"/> object of the specified criteria.</returns>
        internal static OrderStatusList GetByOrderId(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(DataPortal.FetchChild <OrderStatusList>(criteria));
        }
예제 #5
0
        internal static async Task <OrderStatusList> GetByOrderIdLineNumAsync(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <OrderStatusList> >(criteria).ContinueWith(t => t.Result.Child));
        }
예제 #6
0
        public static async Task DeleteOrderStatusAsync(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            await DataPortal.DeleteAsync <OrderStatus>(criteria);
        }
예제 #7
0
        public static async Task <OrderStatus> GetByOrderIdAsync(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(await DataPortal.FetchAsync <OrderStatus>(criteria));
        }
예제 #8
0
        public static void DeleteOrderStatus(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            DataPortal.Delete <OrderStatus>(criteria);
        }
예제 #9
0
        /// <summary>
        /// Returns a <see cref="OrderStatusList"/> object of the specified criteria.
        /// </summary>
        /// <param name="orderId">No additional detail available.</param>
        /// <param name="lineNum">No additional detail available.</param>
        /// <returns>A <see cref="OrderStatusList"/> object of the specified criteria.</returns>
        internal static OrderStatusList GetByOrderIdLineNum(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            return(DataPortal.FetchChild <OrderStatusList>(criteria));
        }
예제 #10
0
        /// <summary>
        /// Returns a <see cref="OrderStatus"/> object of the specified criteria.
        /// </summary>
        /// <param name="orderId">No additional detail available.</param>
        /// <param name="lineNum">No additional detail available.</param>
        /// <returns>A <see cref="OrderStatus"/> object of the specified criteria.</returns>
        public static OrderStatus GetByOrderIdLineNum(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            return(DataPortal.Fetch <OrderStatus>(criteria));
        }
예제 #11
0
        private void Child_Fetch(OrderStatusCriteria criteria)
        {
            bool cancel = false;

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

            RaiseListChangedEvents = false;

            // Fetch Child objects.
            string commandText = String.Format("SELECT [OrderId], [LineNum], [Timestamp], [Status] FROM [dbo].[OrderStatus] {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.Business.OrderStatus.GetOrderStatus(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
예제 #12
0
 /// <summary>
 /// Determines if a record exists in the OrderStatus in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is a <see cref="OrderStatusList"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(OrderStatusCriteria criteria)
 {
     return(PetShop.Business.OrderStatus.Exists(criteria));
 }
예제 #13
0
 /// <summary>
 /// Determines if a record exists in the OrderStatus table in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is an <see cref="OrderStatus"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(OrderStatusCriteria criteria)
 {
     return(PetShop.Business.ExistsCommand.Execute(criteria));
 }
예제 #14
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="OrderStatus"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="OrderStatusCriteria"/> 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(OrderStatusCriteria criteria, ref bool cancel);
예제 #15
0
        protected override void DataPortal_Update()
        {
            bool cancel = false;

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

            if (OriginalOrderId != OrderId || OriginalLineNum != LineNum)
            {
                // Insert new child.
                OrderStatus item = new OrderStatus {
                    OrderId = OrderId, LineNum = LineNum, Timestamp = Timestamp, Status = Status
                };

                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 OrderStatusCriteria {
                    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].[OrderStatus] SET [OrderId] = @p_OrderId, [LineNum] = @p_LineNum, [Timestamp] = @p_Timestamp, [Status] = @p_Status WHERE [OrderId] = @p_OriginalOrderId AND [LineNum] = @p_OriginalLineNum; SELECT [OrderId], [LineNum] FROM [dbo].[OrderStatus] 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_Timestamp", this.Timestamp);
                    command.Parameters.AddWithValue("@p_Status", this.Status);

                    //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();
        }
예제 #16
0
 internal static async Task <OrderStatusList> GetByCriteriaAsync(OrderStatusCriteria criteria)
 {
     return(await DataPortal.FetchAsync <AsyncChildLoader <OrderStatusList> >(criteria).ContinueWith(t => t.Result.Child));
 }
예제 #17
0
 internal static OrderStatusList GetByCriteria(OrderStatusCriteria criteria)
 {
     return(DataPortal.Fetch <OrderStatusList>(criteria));
 }
예제 #18
0
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="OrderStatus"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="OrderStatusCriteria"/> 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(OrderStatusCriteria criteria, ref bool cancel);
예제 #19
0
 /// <summary>
 /// Determines if a record exists in the OrderStatus in the database for the specified criteria.
 /// </summary>
 public static async Task <bool> ExistsAsync(OrderStatusCriteria criteria)
 {
     return(await PetShop.Business.ExistsCommand.ExecuteAsync(criteria));
 }