private void Child_Fetch(CategoryCriteria 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_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())
                        {
                            Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Category' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            OnChildFetched();
        }
        /// <summary>
        /// Returns a <see cref="CategoryInfo"/> object of the specified criteria.
        /// </summary>
        /// <param name="categoryId">No additional detail available.</param>
        /// <returns>A <see cref="CategoryInfo"/> object of the specified criteria.</returns>
        internal static CategoryInfo GetByCategoryId(System.String categoryId)
        {
            var criteria = new CategoryCriteria {
                CategoryId = categoryId
            };


            return(DataPortal.FetchChild <CategoryInfo>(criteria));
        }
Exemplo n.º 3
0
        internal static async Task <CategoryInfoList> GetByCategoryIdAsync(System.String categoryId)
        {
            var criteria = new CategoryCriteria {
                CategoryId = categoryId
            };


            return(await DataPortal.FetchAsync <AsyncChildLoader <CategoryInfoList> >(criteria).ContinueWith(t => t.Result.Child));
        }
        internal static async Task <CategoryInfo> GetByCategoryIdAsync(System.String categoryId)
        {
            var criteria = new CategoryCriteria {
                CategoryId = categoryId
            };


            // Mark as child?
            return(await DataPortal.FetchAsync <CategoryInfo>(criteria));
        }
Exemplo n.º 5
0
        private void Child_Fetch(CategoryCriteria criteria)
        {
            IsReadOnly = false;

            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.Collections.ReadOnlyChild.CategoryInfo.GetCategoryInfo(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            RaiseListChangedEvents = true;

            OnFetched();

            IsReadOnly = true;
        }
 /// <summary>
 /// Determines if a record exists in the Category table in the database for the specified criteria.
 /// </summary>
 public static async Task <bool> ExistsAsync(CategoryCriteria criteria)
 {
     return(await PetShop.Tests.Collections.ReadOnlyChild.ExistsCommand.ExecuteAsync(criteria));
 }
 /// <summary>
 /// Determines if a record exists in the Category table in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is an <see cref="CategoryInfo"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(CategoryCriteria criteria)
 {
     return(PetShop.Tests.Collections.ReadOnlyChild.ExistsCommand.Execute(criteria));
 }
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="CategoryInfo"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="CategoryInfoCriteria"/> 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(CategoryCriteria criteria, SqlConnection connection, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when deleting the child <see cref="CategoryInfo"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="CategoryInfoCriteria"/> 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(CategoryCriteria criteria, ref bool cancel);
 /// <summary>
 /// CodeSmith generated stub method that is called when fetching the child <see cref="CategoryInfo"/> object.
 /// </summary>
 /// <param name="criteria"><see cref="CategoryInfoCriteria"/> 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(CategoryCriteria criteria, ref bool cancel);
Exemplo n.º 11
0
 internal static async Task <CategoryInfoList> GetByCriteriaAsync(CategoryCriteria criteria)
 {
     return(await DataPortal.FetchAsync <AsyncChildLoader <CategoryInfoList> >(criteria).ContinueWith(t => t.Result.Child));
 }
Exemplo n.º 12
0
 internal static CategoryInfoList GetByCriteria(CategoryCriteria criteria)
 {
     return(DataPortal.Fetch <CategoryInfoList>(criteria));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Determines if a record exists in the CategoryInfo in the database for the specified criteria.
 /// </summary>
 /// <param name="criteria">The criteria parameter is a <see cref="CategoryInfoList"/> object.</param>
 /// <returns>A boolean value of true is returned if a record is found.</returns>
 public static bool Exists(CategoryCriteria criteria)
 {
     return(PetShop.Tests.Collections.ReadOnlyChild.CategoryInfo.Exists(criteria));
 }