Business Logic Framework - Tutorial 2:
Assuming you have a Customer class (as show in the included samples) defined that inherits from the Quick Objects Business Framework class BaseBusinessObject then you can do the following to get a DataSet of all the records in the Customers table but only the FirstName field.
| //Business Object is created inside the Using block because it implements IDisposable interface | |
| //so in execution when block is left Dispose of object is automatically called and | |
| //it makes sure that the connections or any resources hold by the Business Object is | |
| //closed or disposed. Otherwise Database connections might be left open and that can lead to | |
| //connection pool saturation. | |
| using (Customers customer = new Customers()) | |
| { | |
| // all field's visible properties will be set to false | |
| customer.UseAllFieldsForDisplay(false); | |
| // FirstName's visible property to set to true | |
| // so only first name will be included in the resulting DataTable | |
| customer.FirstName.Visible = true; | |
| this.GridView.DataSource = customer.Find(); | |
| this.GridView.DataMember = customer.GetResultSetName(); | |
| } | |
| 'Business Object is created inside the Using block because it implements IDisposable interface | |
| 'so in execution when block is left Dispose of object is automatically called and | |
| 'it makes sure that the connections or any resources hold by the Business Object is | |
| 'closed or disposed. Otherwise Database connections might be left open and that can lead to | |
| 'connection pool saturation. | |
| Using customer As Customers = New Customers() | |
| ' all field's visible properties will be set to false | |
| customer.UseAllFieldsForDisplay(False) | |
| ' FirstName's visible property to set to true | |
| ' so only first name will be included in the resulting DataTable | |
| customer.FirstName.Visible = True | |
| Me.GridView.DataSource = customer.Find() | |
| Me.GridView.DataMember = customer.GetResultSetName() | |
| End Using | |
Alternative method would be set each individual field's visible properties explicitly:
| private void AlternativeMethod() | |
| { | |
| using (Customers customer = new Customers()) | |
| { | |
| customer.LastName.Visible = false; | |
| customer.CustomerID.Visible = false; | |
| // FirstName's visible property to set to true | |
| // so only first name will be included in the resulting DataTable | |
| customer.FirstName.Visible = true; | |
| this.GridView.DataSource = customer.Find(); | |
| this.GridView.DataMember = customer.GetResultSetName(); | |
| } | |
| } |
| Private Sub AlternativeMethod() | |
| Using customer = New Customers() | |
| customer.LastName.Visible = False | |
| customer.CustomerID.Visible = False | |
| ' FirstName's visible property to set to true | |
| ' so only first name will be included in the resulting DataTable | |
| customer.FirstName.Visible = True | |
| Me.GridView.DataSource = customer.Find() | |
| Me.GridView.DataMember = customer.GetResultSetName() | |
| End Using | |
| End Sub | |
|
|


This example returns only the FirstName field and the other fields are not returned in the result set. Every record in the table is returned.