public List<ChannelMapping> GetAllMappings() { var lookup = new Dictionary<int, ChannelMapping>(); var result = this.db.Query<SingleMap>(@"SELECT * FROM ChannelMappings"); foreach (var sm in result) { ChannelMapping map; if (!lookup.TryGetValue(sm.Publisher, out map)) { map = new ChannelMapping(); map.Publisher = sm.Publisher; lookup.Add(map.Publisher, map); } if (!map.Subscribers.Contains(sm.Subscriber)) { map.Subscribers.Add(sm.Subscriber); } } return new List<ChannelMapping>(lookup.Values); }
public CompleteChannelMapping FillMapping(ChannelMapping map) { var fullmap = new CompleteChannelMapping(); fullmap.Publisher = this.db.Query<ModuleChannels>(@"SELECT * FROM ModuleInstancesChannels WHERE ID = @ID", new { ID = map.Publisher }).First<ModuleChannels>(); foreach (var s in map.Subscribers) { fullmap.Subscribers.Add(this.db.Query<ModuleChannels>(@"SELECT * FROM ModuleInstancesChannels WHERE ID = @ID", new { ID = s }).First<ModuleChannels>()); } return fullmap; }