I'm trying to get the contacts but while creating an instance of xconnect client, I'm getting the following exception:
Type must have a parameterless constructor (not necessarily public) or a public constructor that only takes parameters that correspond to primitive types
Here is the pseudo code for reference.
using (XConnectClient client = SitecoreXConnectClientConfiguration.GetClient())
{
List<Contact> contacts = null;
contact = client.Get<Contact>(new IdentifiedContactReference(AssemblyFacetInformation.ContactReference, "bcc746fa19cd6fddf0203aa443eebd11"), new ContactExecutionOptions(new ContactExpandOptions(AssemblyFacetInformation.ContactReference)));
var contact = contacts.FirstOrDefault();
var assemblyFacetInformation = contact.GetFacet<AssemblyFacetInformation>(AssemblyFacetInformation.Timezone);
assemblyFacetInformation.TimeZone = windowsTimeZone;
client.SetFacet(contact, AssemblyFacetInformation.Timezone, assemblyFacetInformation);
client.Submit();
}
My Custom model class
public class AssemblyFacetCollectionModel
{
public static XdbModel Model { get; } = BuildAssemblyModel();
static XdbModel BuildAssemblyModel()
{
XdbModelBuilder xdbModelBuilder = new XdbModelBuilder("AssemblyFacetInformation", new XdbModelVersion(1, 0));
xdbModelBuilder.ReferenceModel(CollectionModel.Model);
xdbModelBuilder.DefineFacet<Contact, AssemblyFacetInformation>(AssemblyFacetInformation.DefaultFacetKey);
return xdbModelBuilder.BuildModel();
}
}
This is my facet class
[FacetKey(DefaultFacetKey)]
[Serializable]
public class AssemblyFacetInformation : Facet
{
public const string IdentifierCookieName = "_assembly_visitor_id";
public const string AnalyticsCookieName = "analytics_uuid";
public const string MetroCookieName = "metro";
public const string ContactReference = "Assembly_Visitor";
public const string DefaultFacetKey = "AssemblyFacetKey";
public const string Timezone = "Timezone";
public AssemblyFacetInformation() { }
[JsonProperty("metro")]
public Metro metro { get; set; }
[JsonProperty("geolocated_location")] //From "metro" Cookie
public string GeoLocation { get; set; } //From "metro" Cookie
[JsonProperty("distance_from_metro")]
public float DistanceFromMetro { get; set; } //From "metro" Cookie
[JsonProperty("latitude")]
public float UserLatitude { get; set; } //From "metro" Cookie
[JsonProperty("longitude")]
public float UserLongitude { get; set; } //From "metro" Cookie
[JsonProperty("prioritize_online")]
public bool PrioritizeOnline { get; set; } //From "metro" Cookie
//[JsonProperty("metro")]
//public string ShopSession { get; set; } //From "_shop_session" Cookie
[JsonProperty("time_zone")]
public TimeZoneInfo TimeZone { get; set; }
}
While debugging the process I found that exception originally thrown by the AssemblyFacetCollectionModel class on this line
return xdbModelBuilder.BuildModel();
Did I miss something or doing anything wrong??
Metro
andTimeZone
fields temporarily. I think they are the reason of your issues.One or more local models conflict with the xDB service layer. 'AssemblyFacetKey, 1.0' does not have a remote version'