protected void Load(DataRowCollection dataRows)
        {
            Clear();
            LayerGenConnectionString connectString = new LayerGenConnectionString();

            connectString.ConnectionString = _connectionString;

            foreach (DataRow dr in dataRows)
            {
                Add(new Product(connectString, dr, _concurrency, _useStoredProcedures));
            }
        }
        public void GetByProductId(int fkId)
        {
            LayerGenConnectionString connectString = new LayerGenConnectionString();

            connectString.ConnectionString = _connectionString;
            DataTable dt = DataLayer.FooEnterprises.CustomerProduct.GetByProductId(connectString, fkId);

            if (dt != null)
            {
                Load(dt.Rows);
            }
        }
        /// <summary>
        /// Retrieves rows from the Product table by executing the given stored procedure.
        /// </summary>
        /// <param name="procedureName">The name of the stored procedure to execute.</param>
        public void GetByStoredProcedure(string procedureName)
        {
            LayerGenConnectionString connectString = new LayerGenConnectionString();

            connectString.ConnectionString = _connectionString;

            DataTable dt = DataLayer.FooEnterprises.Product.GetByStoredProcedure(connectString, procedureName, null);

            if (dt != null)
            {
                Load(dt.Rows);
            }
        }
        /// <summary>
        /// Retrieves rows from the Product table, based on the given SQL statement.
        /// </summary>
        /// <param name="sql">The SQL statement to execute.</param>
        /// <param name="sqlParams">Optional <see cref="System.String.Format"/> like parameters</param>
        public void GetBySqlStatement(string sql, params object[] sqlParams)
        {
            LayerGenConnectionString connectString = new LayerGenConnectionString();

            connectString.ConnectionString = _connectionString;

            DataTable dt = DataLayer.FooEnterprises.Product.GetBySqlStatement(connectString, sql, sqlParams);

            if (dt != null)
            {
                Load(dt.Rows);
            }
        }
        /// <summary>
        /// Retrieves all the rows from the Product table.
        /// </summary>
        /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text</param>
        private void GetAll(bool useStoredProcedures)
        {
            LayerGenConnectionString connectString = new LayerGenConnectionString();

            connectString.ConnectionString = _connectionString;

            DataTable dt = DataLayer.FooEnterprises.Product.GetAll(connectString, useStoredProcedures);

            if (dt != null)
            {
                Load(dt.Rows);
            }
        }
        /// <summary>
        /// Retrieves rows from the Customer table by executing the given stored procedure.
        /// </summary>
        /// <param name="procedureName">The name of the stored procedure to execute.</param>
        /// <param name="procedureParams">A dictionary of parameter/value pairs. This can be null if there are no parameters.</param>
        public void GetByStoredProcedure(string procedureName, Dictionary <string, object> procedureParams)
        {
            LayerGenConnectionString connectString = new LayerGenConnectionString();

            connectString.ConnectionString = _connectionString;

            DataTable dt = DataLayer.FooEnterprises.Customer.GetByStoredProcedure(connectString, procedureName, procedureParams);

            if (dt != null)
            {
                Load(dt.Rows);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the given DataRow and explicitly enabling or disabling the
 /// concurrency option.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="dr">The DataRow that contains the data to be loaded into the instance.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Product.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 protected internal Product(LayerGenConnectionString connectionString, DataRow dr, ConcurrencyOptions concurrency) : base(connectionString, dr, concurrency)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the database that matches the given primary key and loading
 /// only the fields specified and explicitly enabling or disabling the
 /// concurrency option. You can also specify if you want data access to be
 /// done with stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="fields">The list of <see cref="BusinessLayer.FooEnterprises.Product.Fields"/> to pull from the database.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Product.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 public Product(LayerGenConnectionString connectionString, int id, List <Fields> fields, ConcurrencyOptions concurrency, bool useStoredProcedures) : base(connectionString, id, fields, concurrency, useStoredProcedures)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the database that matches the given primary key and loading
 /// only the fields specified and explicitly enabling or disabling the
 /// concurrency option.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="fields">The list of <see cref="BusinessLayer.FooEnterprises.Product.Fields"/> to pull from the database.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Product.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 public Product(LayerGenConnectionString connectionString, int id, List <Fields> fields, ConcurrencyOptions concurrency) : base(connectionString, id, fields, concurrency)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the database that matches the given primary key and explicitly
 /// enabling or disabling the concurrency option.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Product.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 public Product(LayerGenConnectionString connectionString, int id, ConcurrencyOptions concurrency) : base(connectionString, id, concurrency)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class, loading a
 /// row from the database that matches the given primary key and loading
 /// only the fields specified.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="fields">The list of <see cref="BusinessLayer.FooEnterprises.Customer.Fields"/> to pull from the database.</param>
 public Customer(LayerGenConnectionString connectionString, int id, List <Fields> fields) : base(connectionString, id, fields)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 public Customer(LayerGenConnectionString connectionString) : base(connectionString)
 {
 }
 public Products(LayerGenConnectionString connectionString, Product.ConcurrencyOptions concurrency)
 {
     _concurrency         = concurrency;
     _useStoredProcedures = false;
     _connectionString    = connectionString.ConnectionString;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the database that matches the given primary key and loading
 /// only the fields specified.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="fields">The list of <see cref="BusinessLayer.FooEnterprises.Product.Fields"/> to pull from the database.</param>
 public Product(LayerGenConnectionString connectionString, int id, List <Fields> fields) : base(connectionString, id, fields)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class, loading a
 /// row from the database that matches the given primary key.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 public Customer(LayerGenConnectionString connectionString, int id) : base(connectionString, id)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class,
 /// optionally using stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 public Customer(LayerGenConnectionString connectionString, bool useStoredProcedures) : base(connectionString, useStoredProcedures)
 {
 }
 public Customers(LayerGenConnectionString connectionString, bool useStoredProcedures)
 {
     _concurrency         = Customer.ConcurrencyOptions.Ignore;
     _useStoredProcedures = useStoredProcedures;
     _connectionString    = connectionString.ConnectionString;
 }
 public Customers(LayerGenConnectionString connectionString, Customer.ConcurrencyOptions concurrency)
 {
     _concurrency         = concurrency;
     _useStoredProcedures = false;
     _connectionString    = connectionString.ConnectionString;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the given DataRow and explicitly enabling or disabling the
 /// concurrency option. You can also specify if you want data access to be
 /// done with stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="dr">The DataRow that contains the data to be loaded into the instance.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Product.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 protected internal Product(LayerGenConnectionString connectionString, DataRow dr, ConcurrencyOptions concurrency, bool useStoredProcedures) : base(connectionString, dr, concurrency, useStoredProcedures)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class, loading a
 /// row from the database that matches the given primary key and loading
 /// only the fields specified. You can also specify if you want data access
 /// to be done with stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="fields">The list of <see cref="BusinessLayer.FooEnterprises.Customer.Fields"/> to pull from the database.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 public Customer(LayerGenConnectionString connectionString, int id, List <Fields> fields, bool useStoredProcedures) : base(connectionString, id, fields, useStoredProcedures)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 public Product(LayerGenConnectionString connectionString) : base(connectionString)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class, loading a
 /// row from the database that matches the given primary key and explicitly
 /// enabling or disabling the concurrency option.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Customer.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 public Customer(LayerGenConnectionString connectionString, int id, ConcurrencyOptions concurrency) : base(connectionString, id, concurrency)
 {
 }
 public Products(LayerGenConnectionString connectionString, bool useStoredProcedures)
 {
     _concurrency         = Product.ConcurrencyOptions.Ignore;
     _useStoredProcedures = useStoredProcedures;
     _connectionString    = connectionString.ConnectionString;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class, loading a
 /// row from the database that matches the given primary key and explicitly
 /// enabling or disabling the concurrency option. You can also specify if you want data
 /// access to be done with stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Customer.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 public Customer(LayerGenConnectionString connectionString, int id, ConcurrencyOptions concurrency, bool useStoredProcedures) : base(connectionString, id, concurrency, useStoredProcedures)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the given DataRow.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="dr">The DataRow that contains the data to be loaded into the instance.</param>
 protected internal Product(LayerGenConnectionString connectionString, DataRow dr) : base(connectionString, dr)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Customer"/> class, loading a
 /// row from the given DataRow.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="dr">The DataRow that contains the data to be loaded into the instance.</param>
 protected internal Customer(LayerGenConnectionString connectionString, DataRow dr) : base(connectionString, dr)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class,
 /// optionally using stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 public Product(LayerGenConnectionString connectionString, bool useStoredProcedures) : base(connectionString, useStoredProcedures)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the given DataRow. You can also specify if you want data access
 /// to be done with stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="dr">The DataRow that contains the data to be loaded into the instance.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 protected internal Product(LayerGenConnectionString connectionString, DataRow dr, bool useStoredProcedures) : base(connectionString, dr, useStoredProcedures)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, loading a
 /// row from the database that matches the given primary key.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="id">The primary key of the row that gets loaded from the database.</param>
 public Product(LayerGenConnectionString connectionString, int id) : base(connectionString, id)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Product"/> class, explicitly enabling
 /// or disabling the concurrency option. You can also specify if you want data access
 /// to be done with stored procedures or Sql text.
 /// </summary>
 /// <param name="connectionString">Sets the connection string to use to connect to the database.</param>
 /// <param name="concurrency">A <see cref="BusinessLayer.FooEnterprises.Product.ConcurrencyOptions"/> value indicating the level of concurrency.</param>
 /// <param name="useStoredProcedures">If true, then all data access will be done using stored procedures. Otherwise, data access will be done using Sql text.</param>
 public Product(LayerGenConnectionString connectionString, ConcurrencyOptions concurrency, bool useStoredProcedures) : base(connectionString, concurrency, useStoredProcedures)
 {
 }