ACAccess<T>
With the instantiation of an ACQueryDefinition, the description of the database query has now been made possible, but the data must still be queried in the database. The class "gip.core.datamodel. ACAccess<T>" is responsible for executing the persistable query.
You can obtain an ACAccess instance by calling the "ACQueryDefinition.NewAccess()" method:
ACAccess<Material> acAccess = acQueryDef.NewAccess<Material>(Material.ClassName, this);
Then call one of the overloaded methods "NavSearch(...)" and pass a database context on which the query is to be executed:
bool succ = acAccess.NavSearch(dbContext);
bool succ = acAccess.NavSearch(dbContext, MergeOption.OverwriteChanges);
The query result is written in the property public IList<T> NavList :
foreach (Material mat in AccessPrimary.NavList)
{
// do something
}
ACAccessNav<T>
The derived class ACAccessNav<T> extends the ACAccess<T> by navigation methods:
public void NavigateFirst();
public void NavigateLast();
public void NavigateNext();
public void NavigatePrev();
T Current { get; }
ACAccessNav<T> is used for navigable business objects that are derived from the base class ACBSONav. You get an instance by calling the NewAccessNav method:
ACAccessNav<Material> _AccessPrimary = acQueryDef.NewAccessNav<Material>(Material.ClassName, this);
In your derivation, override the AccessNav property to return your instance of ACAccessNav<T>:
public override IAccessNav AccessNav { get { return AccessPrimary; } }
If your business object is opened and displayed on the surface, the section on navigation with the navigation keys is visible in the VBRibbonBar, since the overwritten property AccessNav now returns an instance of the interface IAccessNav that implements ACAccessNav<T>. The navigation buttons are automatically bound to the four navigation methods via CommandBinding.
Global search word
If the Enter key is pressed in the search text box in the ribbon bar, another CommandBinding is executed, which is bound to the "Search()" method of the business object. You must explicitly declare this method and implement it according to the following example:
[ACMethodCommand(Material.ClassName, "en{'Search'}de{'Suchen'}", (short)MISort.Search)]
public void Search()
{
AccessPrimary.NavSearch(DatabaseApp, DatabaseApp.RecommendedMergeOption);
OnPropertyChanged("MaterialList");
}
[ACPropertyList(9999, Material.ClassName)]
public IList<Material> MaterialList
{
get
{
return AccessPrimary.NavList;
}
}
The MaterialList contains the query result and is usually bound to a VBDataGrid in the Explorer window. In order for the VBDataGrid to display the query result, trigger the PropertyChanged event by calling the OnPropertyChanged (...) method.