I am implementing custom xDB facets from Sitecore 8.2 to Sitecore 9.3. I have a facet called "Data" and ICentralData Inherited from IElemenet. Now IElement is an obsolute in Sitecore 9.3. It is unclear to me how to implement the facet and element in Sitecore 9.3.
public interface ICentralData : IElement
{
IPreferences Preferences { get; }
IElementCollection<IFavoriteTool> FavoriteTools { get; }
}
// Unclear to replace the below methods in Sitecore 9.3
GetElement, GetCollection, EnsureElement, EnsureCollection
public class CentralData : Element, ICentralData
{
private const string PREFERENCES = "Preferences";
private const string BOOKMARKS = "Bookmarks";
public IPreferences Preferences
{
get { return GetElement<IPreferences>(PREFERENCES); }
}
public IElementCollection<IBookmark> Bookmarks
{
get { return GetCollection<IBookmark>(BOOKMARKS); }
}
public CentralData()
{
this.EnsureElement<IPreferences>(PREFERENCES);
this.EnsureCollection<IBookmark>(BOOKMARKS);
}
}
// would like to understand the replacement of the below methods inside custom facet
GetAttribute, SetAttribute, EnsureAttribute
[Serializable]
public class Data: Facet
{
private const string PERSONID = "PersonId";
private const string centralData = "centralData";
public int PersonId
{
get
{
return GetAttribute<int>(PERSONID);
}
set
{
SetAttribute(PERSONID, value);
}
}
public ICentralData CentralData
{
get { return GetElement<ICentralData>(centralData); }
}
public Data()
{
this.EnsureAttribute<int>(PERSONID);
this.EnsureElement<ICentralData>(centralData);
}
}
As per my understating, I need to create an XConnect custom facet but I'm a bit unclear about Elements and attributes.
Appreciated it anyone can help with this. Thanks in advance!!