Esempio n. 1
0
        //[Transactional(TransactionalTypes.TransactionScope)]
        protected void DataPortal_Delete(DataOptionTypeCriteria 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].[spCFM_DataOptionType_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();
        }
        public static void DeleteDataOptionType(System.Int32 dataOptionTypeID)
        {
            var criteria = new DataOptionTypeCriteria {
                DataOptionTypeID = dataOptionTypeID
            };


            new DataOptionType().DataPortal_Delete(criteria);
        }
        /// <summary>
        /// Returns a <see cref="DataOptionType"/> object of the specified criteria.
        /// </summary>
        /// <param name="createdBy">No additional detail available.</param>
        /// <returns>A <see cref="DataOptionType"/> object of the specified criteria.</returns>
        public static DataOptionType GetByCreatedBy(System.Int32 createdBy)
        {
            var criteria = new DataOptionTypeCriteria {
                CreatedBy = createdBy
            };


            return(new DataOptionType().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="DataOptionType"/> object of the specified criteria.
        /// </summary>
        /// <param name="dataOptionTypeID">No additional detail available.</param>
        /// <returns>A <see cref="DataOptionType"/> object of the specified criteria.</returns>
        public static DataOptionType GetByDataOptionTypeID(System.Int32 dataOptionTypeID)
        {
            var criteria = new DataOptionTypeCriteria {
                DataOptionTypeID = dataOptionTypeID
            };


            return(new DataOptionType().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// CodeSmith generated stub method that is called after the child <see cref="DataOptionType"/> object with the specified criteria has been deleted.
        /// </summary>
        //partial void OnDeleted();
        //partial void OnChildLoading(Csla.Core.IPropertyInfo childProperty, ref bool cancel);

        #endregion


        #region Exists Command

        /// <summary>
        /// Determines if a record exists in the DataOptionType table in the database for the specified criteria.
        /// </summary>
        /// <param name="criteria">The criteria parameter is an <see cref="DataOptionType"/> object.</param>
        /// <returns>A boolean value of true is returned if a record is found.</returns>
        public static DataOptionType Exists(DataOptionTypeCriteria criteria)
        {
            try
            {
                return(new DataOptionType().DataPortal_Fetch(criteria));
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
        /// <summary>
        /// Returns a <see cref="DataOptionType"/> object of the specified criteria.
        /// </summary>
        /// <param name="dataOptionTypeSortID">No additional detail available.</param>
        /// <returns>A <see cref="DataOptionType"/> object of the specified criteria.</returns>
        public static DataOptionType GetByDataOptionTypeSortID(System.Int32?dataOptionTypeSortID)
        {
            var criteria = new DataOptionTypeCriteria {
            };

            if (dataOptionTypeSortID.HasValue)
            {
                criteria.DataOptionTypeSortID = dataOptionTypeSortID.Value;
            }

            return(new DataOptionType().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="DataOptionType"/> object of the specified criteria.
        /// </summary>
        /// <param name="defaultValue">No additional detail available.</param>
        /// <returns>A <see cref="DataOptionType"/> object of the specified criteria.</returns>
        public static DataOptionType GetByDefaultValue(System.Int32?defaultValue)
        {
            var criteria = new DataOptionTypeCriteria {
            };

            if (defaultValue.HasValue)
            {
                criteria.DefaultValue = defaultValue.Value;
            }

            return(new DataOptionType().DataPortal_Fetch(criteria));
        }
        /// <summary>
        /// Returns a <see cref="DataOptionType"/> object of the specified criteria.
        /// </summary>
        /// <param name="updatedBy">No additional detail available.</param>
        /// <returns>A <see cref="DataOptionType"/> object of the specified criteria.</returns>
        public static DataOptionType GetByUpdatedBy(System.Int32?updatedBy)
        {
            var criteria = new DataOptionTypeCriteria {
            };

            if (updatedBy.HasValue)
            {
                criteria.UpdatedBy = updatedBy.Value;
            }

            return(new DataOptionType().DataPortal_Fetch(criteria));
        }
Esempio n. 9
0
        private DataOptionTypeList DataPortal_Fetch(DataOptionTypeCriteria criteria)
        {
            bool cancel = false;

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

            //RaiseListChangedEvents = false;

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[spCFM_DataOptionType_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_DataOptionTypeSortIDHasValue", criteria.DataOptionTypeSortIDHasValue);
                    command.Parameters.AddWithValue("@p_DefaultValueHasValue", criteria.DefaultValueHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            var rowParser = reader.GetRowParser <CFMData.DataOptionType>();
                            do
                            {
                                this.Add(CFMData.DataOptionType.GetDataOptionType(rowParser, reader));
                            }while(reader.Read());
                        }
                        OnFetched();
                        return(this);
                    }
                }
            }

            //RaiseListChangedEvents = true;
        }
Esempio n. 10
0
        private DataOptionType DataPortal_Fetch(DataOptionTypeCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(null);
            }
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[spCFM_DataOptionType_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_DataOptionTypeSortIDHasValue", criteria.DataOptionTypeSortIDHasValue);
                    command.Parameters.AddWithValue("@p_DefaultValueHasValue", criteria.DefaultValueHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedOnHasValue", criteria.UpdatedOnHasValue);
                    command.Parameters.AddWithValue("@p_UpdatedByHasValue", criteria.UpdatedByHasValue);
                    using (var reader = command.ExecuteReader())
                    {
                        var rowParser = reader.GetRowParser <DataOptionType>();
                        if (reader.Read())
                        {
                            return(GetDataOptionType(rowParser, reader));
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.DataOptionType' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }
            OnFetched();
        }
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="DataOptionType"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="DataOptionTypeCriteria"/> 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(DataOptionTypeCriteria criteria, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="DataOptionType"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="DataOptionTypeCriteria"/> 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(DataOptionTypeCriteria criteria, SqlConnection connection, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="DataOptionType"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="DataOptionTypeCriteria"/> 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 OnChildFetching(DataOptionTypeCriteria criteria, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the <see cref="DataOptionType"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="DataOptionTypeCriteria"/> 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(DataOptionTypeCriteria criteria, ref bool cancel);
        public static DataOptionTypeList GetByCriteria(DataOptionTypeCriteria criteria)
        {
            return(new DataOptionTypeList().DataPortal_Fetch(criteria));
//            return DataPortal.Fetch<DataOptionTypeList>(criteria);
        }