Using Accelerator Data Categories is a great way to improve performance when you are selecting data. By default, all fields defined by a data map will be selected when the am_Select
or am_Fetch
methods are called. If you have a lot of maps defined and only want a couple fields back, you can improve performance by creating a category and only applying that category to the data maps you want to select. This not only saves on the SQL statement, but also on the overhead of passing all the unnecessary data back to the UX logic that is not needed. Categories also come in handy when you have a lot of SQL joins defined, but don't always have the need to get the fields defined on the joins. The Accelerator is smart enough to only create a join if 1 or more data maps refer to the join. This makes it very easy to customize what joins are used by specifying a data category on the data maps that reference the join. It is also important to note that a data map can have multiple categories applied and that you can name the category whatever you want. When you call the am_Select
or am_Fetch
methods, simply pass the category you want to use.
In this example, there is a join defined to get the command name and description. Notice that the data maps only have the data category "FWFA_COMMANDS"
applied. If no data category is specified on a map, then "*ALL"
is used as the default. Once a data category is applied, the new data category replaces the default of "*ALL"
. Furthermore, If no category is specified when calling the am_Select
or am_Fetch
methods, then it is defaulted to "*ALL"
as well. In this case, if "*ALL"
is used by the am_Select
, all fields except the Command Name and Description will be selected. If the category "FWFA_COMMANDS"
is used, then the SQL join will be created and the Command Name and Description will be selected.
Code from Data Maps:
// Define default category list
var categoryList = new List<string> {"*ALL", "FWFA_COMMANDS"};
maps.am_AddDataMap("FWFAID", FrameworkAuthEntity.AuthorizationIDProperty, dataCategories: categoryList);
maps.am_AddDataMap("FWFAUGID", FrameworkAuthEntity.GroupIDProperty, dataCategories: categoryList);
maps.am_AddDataMap("FWFALV", FrameworkAuthEntity.LevelProperty, dataCategories: categoryList);
maps.am_AddDataMap("FWFAPID", FrameworkAuthEntity.ParentAuthorizationIDProperty, dataCategories: categoryList);
maps.am_AddDataMap("FWFAOBTY", FrameworkAuthEntity.ObjectTypeProperty, dataCategories: categoryList);
// Only use these data maps when the category "FWFA_COMMANDS" is used
maps.am_AddDataMap(string.Format("{0}.{1}", FWCMTableName, "FWCMNM"),
FrameworkAuthEntity.CommandNameProperty,
targetTable: FWCMTableName,
dataCategories: new List<string> { "FWFA_COMMANDS" });
maps.am_AddDataMap(string.Format("{0}.{1}", FWCMTableName, "FWCMDS"),
FrameworkAuthEntity.CommandDescriptionProperty,
targetTable: FWCMTableName,
dataCategories: new List<string> {"FWFA_COMMANDS" });
Code demonstrating how to call am_Select
while specifying a category:
// Select based on category "FWFA_COMMANDS"
am_Select(new AB_SelectInputArgs<frameworkauthentity>(){ ap_Category = "FWFA_COMMANDS" })