Skip to main content
added 992 characters in body
Source Link
eglasius
  • 456
  • 3
  • 8

Update 1: example of an expression. One additional challenge there is that you need to get the type of the facet so that you can feed it into the GetContactPredicate call:

    private static Expression<Func<Contact, bool>> GetContactPredicate(Type facetType, string facetKey, string propertyName, object value)
    {
        var contact = Expression.Parameter(typeof(Contact));
        var facet = Expression.Call(contact, "GetFacet", new [] {facetType}, Expression.Constant(facetKey));
        var valueInIndex = Expression.Property(facet,  propertyName);
        var valuesComparisson = Expression.LessThanOrEqual(valueInIndex, Expression.Constant(value));
        return Expression.Lambda<Func<Contact, bool>>(valuesComparisson, contact);
    }

Sample call with hardcoded values:

    GetContactPredicate(typeof(MaturityMailDates), MaturityMailDates.DefaultFacetKey, "ReminderEmailDate", DateTimeProvider.GetUtcNow());

The problem is XConnect doesn’t support custom method calls in its linq query expressions.

This prevents using any kind of special logic to get to those facet properties to be compared.

What you can do instead, is drop down to issuing the Expression directly so that Iit can still be a general solution without having the need to have the method calls within the Expression passed to XConnect.

The problem is XConnect doesn’t support custom method calls in its linq query expressions.

This prevents using any kind of special logic to get to those facet properties to be compared.

What you can do instead, is drop down to issuing the Expression directly so that I can still be a general solution without having the need to have the method calls within the Expression passed to XConnect.

Update 1: example of an expression. One additional challenge there is that you need to get the type of the facet so that you can feed it into the GetContactPredicate call:

    private static Expression<Func<Contact, bool>> GetContactPredicate(Type facetType, string facetKey, string propertyName, object value)
    {
        var contact = Expression.Parameter(typeof(Contact));
        var facet = Expression.Call(contact, "GetFacet", new [] {facetType}, Expression.Constant(facetKey));
        var valueInIndex = Expression.Property(facet,  propertyName);
        var valuesComparisson = Expression.LessThanOrEqual(valueInIndex, Expression.Constant(value));
        return Expression.Lambda<Func<Contact, bool>>(valuesComparisson, contact);
    }

Sample call with hardcoded values:

    GetContactPredicate(typeof(MaturityMailDates), MaturityMailDates.DefaultFacetKey, "ReminderEmailDate", DateTimeProvider.GetUtcNow());

The problem is XConnect doesn’t support custom method calls in its linq query expressions.

This prevents using any kind of special logic to get to those facet properties to be compared.

What you can do instead, is drop down to issuing the Expression directly so that it can still be a general solution without having the need to have the method calls within the Expression passed to XConnect.

Source Link
eglasius
  • 456
  • 3
  • 8

The problem is XConnect doesn’t support custom method calls in its linq query expressions.

This prevents using any kind of special logic to get to those facet properties to be compared.

What you can do instead, is drop down to issuing the Expression directly so that I can still be a general solution without having the need to have the method calls within the Expression passed to XConnect.