Hi, i have simple categories and items structure. I made custom Data Type with Content Picker and administrator chooses category when he/she adds item. The problem is that i can not access category title.
int itemCategoryId = allOffer.GetPropertyValue<int>("itemCategory");
Returns only category id. I can not access categoryTitle.
As i see there is not any Include() method in umbraco which lets me to join tables, what else can i do besides of selecting entire category data from categories table by itemCategoryId.
Can you expand a bit more on what you mean? When you say you've made a custom Data Type with Content Picker do you mean you've made a "Data Type" in the developer section that is using the Content Picker property editor?
Working on the assumption that the above is true, and that you are now trying to access the selected category in your Razor template then you need to do the following:
var myCategory = Umbraco.TypedContent(itemCategoryId);
This should return your category but you will need to check for null just incase the category gets deleted :-)
If you are using a version of Umbraco with PropertyValueConverters enabled you should be able to do the following:
var myCategory = allOffer.GetPropertyValue<IPublishedContent>("itemCategory");
Yes i have made Data Type in developers section which is using Content Picker property editor.
I made almost same, because allOffers.GetPropertyValue is returning picked property's Id. I just hoped it to return whole object instead of only Id.
So i had to access Category titles with code below :
How to join tables in Umbraco ?
Hi, i have simple categories and items structure. I made custom Data Type with Content Picker and administrator chooses category when he/she adds item. The problem is that i can not access category title.
int itemCategoryId = allOffer.GetPropertyValue<int>("itemCategory");
Returns only category id. I can not accesscategoryTitle
.As i see there is not any Include() method in umbraco which lets me to join tables, what else can i do besides of selecting entire category data from categories table by
itemCategoryId
.Hi Saba,
Can you expand a bit more on what you mean? When you say you've made a custom Data Type with Content Picker do you mean you've made a "Data Type" in the developer section that is using the Content Picker property editor?
Working on the assumption that the above is true, and that you are now trying to access the selected category in your Razor template then you need to do the following:
var myCategory = Umbraco.TypedContent(itemCategoryId);
This should return your category but you will need to check for null just incase the category gets deleted :-)
If you are using a version of Umbraco with PropertyValueConverters enabled you should be able to do the following:
var myCategory = allOffer.GetPropertyValue<IPublishedContent>("itemCategory");
Does that help?
Thanks
Nik
Hi Nik,
Yes i have made Data Type in developers section which is using Content Picker property editor.
I made almost same, because
allOffers.GetPropertyValue
is returning picked property's Id. I just hoped it to return whole object instead of only Id. So i had to accessCategory
titles with code below :I just hoped there was something like
lazy loading
in Umbraco.is working on a reply...