/// <summary> /// Helper, automates the loading of sources items from DB. /// </summary> /// <param name="source"></param> void LoadSourceItemsFromPersistence(EventSource source) { List <EventBase> items = _persistenceHelper.SelectDynamicType <EventBase>(new MatchExpression("SourceId", source.Id), null); Dictionary <string, List <EventBase> > itemsByChannel = new Dictionary <string, List <EventBase> >(); foreach (RssNewsEvent item in items) { item.Channel = source.GetChannelByName(item.ChannelId, true); if (itemsByChannel.ContainsKey(item.ChannelId) == false) { itemsByChannel.Add(item.ChannelId, new List <EventBase>()); } itemsByChannel[item.ChannelId].Add(item); } foreach (string name in itemsByChannel.Keys) { // Handle the relation to persistence. EventSourceChannel channel = source.GetChannelByName(name, false); channel.AddItems(itemsByChannel[name]); } }
/// <summary> /// Helper, automates the loading of sources items from DB. /// </summary> /// <param name="source"></param> void LoadSourceItemsFromPersistence(EventSource source) { List<EventBase> items = _persistenceHelper.SelectDynamicType<EventBase>(new MatchExpression("SourceId", source.Id), null); Dictionary<string, List<EventBase>> itemsByChannel = new Dictionary<string, List<EventBase>>(); foreach (RssNewsEvent item in items) { item.Channel = source.GetChannelByName(item.ChannelId, true); if (itemsByChannel.ContainsKey(item.ChannelId) == false) { itemsByChannel.Add(item.ChannelId, new List<EventBase>()); } itemsByChannel[item.ChannelId].Add(item); } foreach (string name in itemsByChannel.Keys) { // Handle the relation to persistence. EventSourceChannel channel = source.GetChannelByName(name, false); channel.AddItems(itemsByChannel[name]); } }