AI OnAI Off
I was able to work around this issue by using a SelectionQuery instead of SelectionFactory for the TableFilter.Column property.
For the record:
[ServiceConfiguration(typeof(ISelectionQuery))] public class TableColumnSelectionQuery : ISelectionQuery { public ISelectItem GetItemByValue(string value) { return TableHelper.GetCurrentTableColumns().FirstOrDefault(column => column.Value.Equals(value)); } public IEnumerable<ISelectItem> GetItems(string query) { return TableHelper.GetCurrentTableColumns() .Where(column => column.Text.StartsWith(query, StringComparison.OrdinalIgnoreCase)); } } public class TableFilter { [AutoSuggestSelection(typeof(TableColumnSelectionQuery))] public string Column { get; set; } public string Value { get; set; } }
Using this approach GetItems() on the TableColumnSelectionQuery is called whenever the user interacts with the drop down. At this point I can look up which table the user is working with and provide the relevant list of columns.
Greetings.
I think I am having an issue with Episerver's caching of a SelectionFactory's ISelectItem objects. I have a block which consists of a PropertyList property. Moreover, T contains a property that is a backed by a SelectionFactory.
Usually when I use SelectionFactory in Episerver, the GetSelections() function is invoked every time the owner content is loaded (the page or block that contains the respective property). This does not seem to be the case for custom objects used within PropertyLists. In this case, the "owner content" of the SelectionFactory is a POCO and appears to be created once and then put into the cache.
To clarify my issue, the folloing code might help:
When the user creates an instance of TableBlock, he gives it a name, for instance "Economy Table". He then proceeds to add filters to this table's columns through the block's Filters property. The underlying POCO here (TableFilter) has a Column property that shows a dropdown based on values returned from TableColumnSelectionFactory.GetSelections(). I want my SelectionFactory to return different values here for the "Economy Table" than for say the "Sports Results Table".
My problem occurs when the user creates another instance of TableBlock. This time he names the block "Foods Table". For some reason, when the user attempts to add filters to the "Foods Table", the options he can choose from is related to the "Economy Table". This seems to be because the TableFilter POCO is cached by Episerver and the options for the Column property are still same ones that were returned from TableColumnSelectionFactory.GetSelections() the first time it was called.
I hope this made sense, if not I will be happy to provide further information.
Can anyone help me make Episerver stop caching this particular object or point me in the direction how to solve this problem?
Thanks!