Encapsulating the retrieved Dataset using business objects

Now that you've laid out all the groundwork for parameterized search at the data tier, let's move on to the logic (business objects) tier.

You can probably recall that in the previous chapter you've created the AccountSummary and AccountSummaryCollection business object classes. To refresh your memory, these two classes encapsulate a DataSet containing data from the Accounts table and expose two properties — the FirstName and LastName of the account. The AccountSummaryCollection class can be plugged directly into a DataGrid control for display.

You can reuse these classes as the DataSet retrieved via the search is structurally the same. You can add the code to do this in the global Application class of your SalesForceApp project.

public AccountSummaryCollection GetAccountsByParameters (AccountSearchParameters SearchParameters, int TotalRecords, int PageNumber, int PageSize, string SortColumn, GlobalVariables.SortingOrder SortDirection)

IDataLibPlugin _plugin =

GlobalArea.PluginManager.GetActivePlugin; DataSet _accountsSummaryDataset =

_plugin.GetAccountsByParameters (SearchParameters,

TotalRecords, PageNumber, PageSize, SortColumn, SortDirection); DataTable _accountsSummaryDatatable =

_accountsSummaryDataset.Tables["Accounts"];

return new AccountSummaryCollection (_accountsSummaryDatatable);

public int GetAccountsCountByParameters

(AccountSearchParameters SearchParameters)

IDataLibPlugin _plugin =

GlobalArea.PluginManager.GetActivePlugin; return

_plugin.GetAccountsCountByParameters (SearchParameters);

If you wish to show more columns in the search results listing besides the FirstName and LastName columns, you can add more columns of your own by adding the respective properties to the AccountSummary class.

Was this article helpful?

0 0

Post a comment