Filter Child Content items by Date
I have a dynamic module with two content types 1) Traded Funds and 2) Historic Data the second of which has the first as its parent. Each historic data entry has a date and also stores two additional fields storing the traded values for that day.
I'm creating a custom widget using MVC and trying to query the historic data filtering by dates so that the user can view only a selected number of days' worth of financial data.
Here's a sample of code I'm using:
var dynamicModuleManager = new DynamicModuleManager(String.Empty);Type typeETF = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.TradedFunds.ExchangeTradedFund");Type typeHistoricData = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.TradedFunds.HistoricDataEntry");//get the fund that we're dealing withvar fundItem = dynamicModuleManager.GetDataItems(typeETF).Where(x => x.UrlName == urlName && x.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && x.Visible == true).First();var newFromDate = from.Subtract(TimeSpan.FromDays(1));var newToDate = to.AddDays(1);//now get the child itemsvar childItems = fundItem.GetChildItems(typeHistoricData) .Where(x => x.Status == ContentLifecycleStatus.Live && x.Visible == true && x.GetValue<DateTime?>("Date") > newFromDate && x.GetValue<DateTime?>("Date") < newToDate).ToList();var childItems2 = dynamicModuleManager.GetDataItems(typeHistoricData).Where(x => x.SystemParentId == fundItem.OriginalContentId && x.Status == ContentLifecycleStatus.Live && x.Visible == true && x.GetValue<DateTime?>("Date") > newFromDate && x.GetValue<DateTime?>("Date") < newToDate).ToList();In both attempts childItems and childItems2 the count returned is zero.
There is data available for the days I'm selecting so I'm not sure why this is happening. I seem to be able to filter/sort on other fields except Date.