IAccountServiceAccountQuery Method

Gets the accounts corresponding to query criteria.

Namespace:  Dundas.BI.AccountServices
Assembly:  Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (24.2.0.1000)
Syntax
IList<Account> AccountQuery(
	int pageNumber,
	int pageSize,
	IList<Tuple<AccountQueryField, SortDirection>>? orderBy,
	ICollection<AccountQueryFilterRule>? filter
)

Parameters

pageNumber
Type: SystemInt32
The page number, or 0 to indicate that all pages should be returned.
pageSize
Type: SystemInt32
The number of results in each page (ignored if pageNumber is 0).
orderBy
Type: System.Collections.GenericIListTupleAccountQueryField, SortDirection
The sort order of the result, or if the order does not matter.
filter
Type: System.Collections.GenericICollectionAccountQueryFilterRule
The filter rules which should be applied to the query, or if no filtering is required.

Return Value

Type: IListAccount
The collection of Accounts matching the query criteria.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionpageNumber is less than zero; -or- pageSize is less or equal to than zero.
InvalidOperationExceptionfilter contains invalid rule.
NoPrivilegeException

The caller does not have system administration privileges.

-or-

The caller is associated with a tenant, but does not have administration privileges for that tenant.

InvalidSessionExceptionThe caller context is not associated with a valid session.
Remarks
If the caller is associated with a tenant, the results will be filtered so that only accounts associated with that tenant are included.
Examples

This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, queries accounts that start with the letter 'A', and then shutdown the Dundas BI engine.

C#
using Dundas.BI;
using Dundas.BI.AccountServices;
using Dundas.BI.Services;
using System.Collections.ObjectModel;
   ...

// Create the engine.
EngineManager.CreateEngine(
    // Path to the application's data folder. Type: System.String
    @"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data"
);

try
{
    // Start the Dundas BI Engine.
    EngineManager.StartEngine();

    // Create a caller context not associated with any session.
    using(Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null))
    {

        // LogOn.
        LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn(
            // The account name. Type: System.String
            "admin",
            // The password. Type: System.String
            "1234",
            // Delete other sessions for the logon to succeed. Type: System.Boolean
            true,
            // Culture to associate with the session, or null. Type: System.Globalization.CultureInfo
            null
        );

        // Set the current session ID.
        using(Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId(
            logOnResult.Session.Id
        );

        // Get the account service.
        IAccountService accountService =
            Engine.Current.GetService<IAccountService>();

        // Order by name descending.
        var orderQueryBy = 
            new List<Tuple<AccountQueryField, SortDirection>>() {
                new Tuple<AccountQueryField, SortDirection>(AccountQueryField.Name, SortDirection.Descending)
            };

        // Get the accounts that start with the letter 'a'.
        var rules = new List<AccountQueryFilterRule>();
           rules.Add(
               new AccountQueryFilterRule(
                AccountQueryField.Name, 
                QueryFilterOperator.StartsWith, 
                "a"
                )
            );

        // Get the accounts.  
        var accounts = 
            accountService.AccountQuery(
                // The first page.
                1,
                // Get maximum ten entries during query.
                10,
                // pass the order by.
                orderQueryBy,
                // pass the query rules.
                rules
            );

        // Write the account names to the console.
        foreach(var account in accounts)
        {
            Console.WriteLine(account.Name);
        }
    }
}
finally
{
    EngineManager.ShutdownEngine();
}
See Also