Quick Objects Documentation Akal Tech Logo
Return All Records From a Table

Glossary Item Box

Business Logic Framework - Tutorial 1:

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.

1 private void BindGrid()  
2 {  
3     using (Customers customer = new Customers())  
4     {  
5         this.GridView.DataSource = customer.Find();  
6         this.GridView.DataMember = customer.GetResultSetName();  
7     }  
8
1 Private Sub BindGrid()  
2     Using customer As Customers = New Customers()  
3         Me.GridView.DataSource = customer.Find()  
4         Me.GridView.DataMember = customer.GetResultSetName()  
5     End Using  
6 End Sub 
7  

 Alternative Method:

1 private void AlternativeMethod()  
2 {  
3     Customers customer = new Customers();  
4     this.GridView.DataSource = customer.Find();  
5     this.GridView.DataMember = customer.GetResultSetName();  
6     customer.Dispose();  
7
1 Private  Sub AlternativeMethod()  
2     Dim customer As Customers = New Customers()  
3     Me.GridView.DataSource = customer.Find()  
4     Me.GridView.DataMember = customer.GetResultSetName()  
5     customer.Dispose()  
6 End Sub 
7  

 

In the first line we enclosed the Customers object instance creation inside the using statement, this ensures that the Dispose method is called after all the code enclosed in the { } braces is executed. You could alternatively do:

 This example returns every field (that is mapped to a property in the Customer class).  Every record in the table is returned.

As you can see that all the fields from the Customer table are shown in the result set.