Beispiel #1
0
        /// <summary>
        /// Retrieves data from the data base into a CSLA editable child business object of type <see cref="OrderStatus"/>
        /// using the criteria provided.
        /// </summary>
        /// <param name="criteria">Object of type <see cref="OrderStatusCriteria"/></param>
        /// <returns></returns>
        private void Child_Fetch(OrderStatusCriteria 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_OrderStatus_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.OrderStatus' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnChildFetched();
        }
Beispiel #2
0
        /// <summary>
        /// Deletes data in the data base using the criteria specified in the OrderStatusCriteria object.
        /// </summary>
        /// <param name="criteria">Object of type <see cref="OrderStatusCriteria"/></param>
        /// <returns></returns>
        protected void DataPortal_Delete(OrderStatusCriteria criteria, SqlConnection connection)
        {
            bool cancel = false;

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

            using (var command = new SqlCommand("[dbo].[CSLA_OrderStatus_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();
        }
        /// <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>
        public static OrderStatusList GetByOrderId(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(DataPortal.Fetch <OrderStatusList>(criteria));
        }
        /// <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>
        public static OrderStatusList GetByOrderIdLineNum(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            return(DataPortal.Fetch <OrderStatusList>(criteria));
        }
        public static async Task <OrderStatusList> GetByOrderIdAsync(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(await DataPortal.FetchAsync <OrderStatusList>(criteria));
        }
Beispiel #6
0
        internal static async Task <OrderStatus> GetByOrderIdAsync(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <OrderStatus> >(criteria).ContinueWith(t => t.Result.Child));
        }
Beispiel #7
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>
        internal static OrderStatus GetByOrderId(System.Int32 orderId)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId
            };


            return(DataPortal.FetchChild <OrderStatus>(criteria));
        }
Beispiel #8
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>
        internal static OrderStatus GetByOrderIdLineNum(System.Int32 orderId, System.Int32 lineNum)
        {
            var criteria = new OrderStatusCriteria {
                OrderId = orderId, LineNum = lineNum
            };


            return(DataPortal.FetchChild <OrderStatus>(criteria));
        }
Beispiel #9
0
        private void DataPortal_Fetch(OrderStatusCriteria 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_OrderStatus_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.OrderStatus.GetOrderStatus(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();
        }
 /// <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.Tests.StoredProcedures.ExistsCommand.ExecuteAsync(criteria));
 }
 /// <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.Tests.StoredProcedures.OrderStatus.Exists(criteria));
 }
 /// <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);
 public static async Task <OrderStatusList> GetByCriteriaAsync(OrderStatusCriteria criteria)
 {
     return(await DataPortal.FetchAsync <OrderStatusList>(criteria));
 }
 public static OrderStatusList GetByCriteria(OrderStatusCriteria criteria)
 {
     return(DataPortal.Fetch <OrderStatusList>(criteria));
 }
Beispiel #15
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="OrderStatus"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="OrderStatusCriteria"/> object containing the criteria of the object to delete.</param>
 /// <param name="connection"></param>
 /// <param name="cancel">Value returned from the method indicating whether the object deletion should proceed.</param>
 partial void OnDeleting(OrderStatusCriteria criteria, SqlConnection connection, ref bool cancel);
Beispiel #16
0
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <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);