Welcome to the forums Marcio!
As Edhy said, you'll typically need to create fill methods (see the help file) to load the BO. There are a few that are built in that are pretty handy.
- FillByPrimaryKey: fill BO with a single record, using the PK of the table.
- FillByParentPrimaryKey: fill BO with records matching a FK to a parent table (think fill orders for a single customer).
- FillDataTable: This is what you'll use to build your own.
Here is one I use in test apps a lot, just to load some data into a BO for some other test I'm doing. This goes into the BO code file.
/// <summary>
/// Fill the BO with the indicated number of records. This is
/// generic enough to use with any BO.
/// </summary>
public void FillTopN(int n)
{
//-- Build SQL Statement.
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.AppendFormat("Select Top {0} *\n", n);
sqlBuilder.AppendFormat("From {0}", this.TableName);
//-- Load data.
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = sqlBuilder.ToString();
this.FillDataTable(cmd);
}
}
Let us know if you run into any problems.