I had a search working on my umbraco site where I was getting a load of events and filtering them but now it is throwing a weird error: The alias datatypes have not changed. Any ideas?
Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Line 39: Umbraco.Core.Services.IContentService cs = ApplicationContext.Current.Services.ContentService;
Line 40: IEnumerable itemList = Enumerable.Empty();
Line 41: itemList = cs.GetChildren(EventsParent).OrderByDescending(x => x.GetValue("simpleEventDateFrom"));
Line 42: String[] catlist = itemList.Select(I => Convert.ToString(I.GetValue("simpleEventCategory"))).ToArray();
Line 43:
Seeing this same issue all of a sudden out of the blue with Umbraco 7.2.4
private void PublishedHandler_Published(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
var contentService = new ContentService();
foreach (var node in args.PublishedEntities)
{
var someProperty = node.GetValue<string>("someAlias");
}
}
Gives me an error:
Message "The given key was not present in the dictionary."
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Collections.ObjectModel.KeyedCollection`2.get_Item(TKey key)
at Umbraco.Core.Models.ContentBase.GetValue[TPassType](String propertyTypeAlias)
Filtering IContent
Hi,
I had a search working on my umbraco site where I was getting a load of events and filtering them but now it is throwing a weird error: The alias datatypes have not changed. Any ideas?
Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Line 39: Umbraco.Core.Services.IContentService cs = ApplicationContext.Current.Services.ContentService; Line 40: IEnumerable itemList = Enumerable.Empty(); Line 41: itemList = cs.GetChildren(EventsParent).OrderByDescending(x => x.GetValue("simpleEventDateFrom")); Line 42: String[] catlist = itemList.Select(I => Convert.ToString(I.GetValue("simpleEventCategory"))).ToArray(); Line 43:
Source File: d:\inetpub\wwwroot\roundsquare-uat\httpdocs\Views\SimpleEvents.cshtml Line: 41
Stack Trace:
This is my code: where simpleEventDateFrom is my alias datatype
var EventsParent = 1460;
Umbraco.Core.Services.IContentService cs = ApplicationContext.Current.Services.ContentService; IEnumerable itemList = Enumerable.Empty(); itemList = cs.GetChildren(EventsParent).OrderByDescending(x => x.GetValue("simpleEventDateFrom"));
Seeing this same issue all of a sudden out of the blue with Umbraco 7.2.4
Gives me an error:
Hi Zac,
Did you try to use GetPropertyValue method?
Hi Alex,
It was a silly question, and I realised as soon as I posted it.
I just expected it not to throw an exception, is all (like IPublishedContent). It was fine as soon as I checked if the content node had that property.
Cheers, Zac
is working on a reply...