Last active
October 4, 2018 20:14
-
-
Save greggnakamura/7bd729aa6e3889cc2b354bafcc12f65c to your computer and use it in GitHub Desktop.
Kentico: Custom Table `ItemKeyName` set to non-Primary key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* default */ | |
form.ItemID = QueryHelper.GetInteger(ItemKeyName, 0); | |
/* by `ItemGUID` */ | |
var ItemKeyNameID = QueryHelper.GetGuid(ItemKeyName, Guid.Empty); | |
/* option 1: get `ItemID` by custom table generated code */ | |
/* saved code will be placed in /App_Code/CMSClasses */ | |
form.ItemID = CMS.CustomTables.CustomTableItemProvider | |
.GetItems<SubscribeToContentAlertItem>() | |
.WhereEquals(ItemKeyName, ItemKeyNameID) | |
.Column("ItemID") | |
.FirstObject?.ItemID ?? 0; | |
/* option 2: get `ItemID` by custom table W/O generated code */ | |
form.ItemID = CMS.CustomTables.CustomTableItemProvider | |
.GetItems(customTable.ClassName) | |
.WhereEquals(ItemKeyName, ItemKeyNameID) | |
.Column("ItemID").FirstObject?.ItemID ?? 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment