My custom rule checks if it is contact's birthday today. Birthdate from Personal facet and current date are compared (respectively their months and days). Following code should do it (at least by my humble guess):
public Expression<Func<Contact, bool>> CreateContactSearchQuery(IContactSearchQueryContext context)
{
return contact => contact.Personal().Birthdate.HasValue && contact.Personal().Birthdate.Value.Month == DateTime.Now.Month && contact.Personal().Birthdate.Value.Day == DateTime.Now.Day;
}
But as mentioned in the title: YourLinqIsTooStrongException is thrown in logs when I try to do segmented list. See:
Exception: Sitecore.XConnect.Search.YourLinqIsTooStrongException
Message: Unsupported query: (VisitMember):
Convert([contact].Personal().Birthdate).Month
Source: Sitecore.Xdb.Common.Web at Sitecore.Xdb.Common.Web. Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory) at Sitecore.XConnect.Client.XConnectSynchronousExtensions. SuspendContextLock[TResult](Func`1 taskFactory) at Sitecore.XConnect.Client. XConnectSynchronousExtensions.GetBatchEnumeratorSync[TEntity](IAsyncQueryable`1 asyncQueryable, Int32 defaultBatchSize) at Sitecore.XConnect.Segmentation. SegmentationEngine.<>c.<CountContacts>b__24_0(IAsyncQueryable`1 contacts) at Sitecore.XConnect.Segmentation. SegmentationEngine.PerformSearch[T](IContactSearchQueryFactory queryFactory, Func`2 searchWork, Byte[] syncToken, ContactExpandOptions expandOptions) at Sitecore.XConnect.Segmentation.SegmentationEngine. CountContacts(IContactSearchQueryFactory queryFactory) at Sitecore.Shell.Applications.Analytics.SegmentBuilder. SegmentBuilderForm.GetFilterSectionHtml(XElement filter, Boolean fillVisitorCount) at Sitecore.Shell.Applications.Analytics. SegmentBuilder.SegmentBuilderForm.InitializeFilters() at Sitecore.Shell. Applications.Analytics.SegmentBuilder.SegmentBuilderForm.Initialize(String value)
And the error shown on screen says basically the same:
I tried to convert values into string using MMdd format for both but had similar results.
Very similar question has already been asked here: List segmentation on custom rule YourLinqIsTooStrongException error
Difference is that in question already answered there is custom facet, while in my case I only try to access value of Personal facet.
In mentioned question there is advised to just simplify solution for Sitecore predicate engine and also to not forget to register condition in Automation Engine. Which I also did (created new XML file as described here).
So to my question(s) - how should I proceed? Should I simplify the condition somehow more? Is there a way to check that my condition is registered correctly?
Edits: Added clarification when exactly the error is thrown.