public EntityDictionary(IEnumerable <Entity> ents) { NameToEntity = ImmutableDictionary <string, Entity> .Empty.ToBuilder(); NameToEntity.AddRange(ents.ToDictionary(e => e.Name)); PosToName = ImmutableDictionary <Position, string> .Empty.ToBuilder(); PosToName.AddRange(NameToEntity.ToDictionary(kv => kv.Value.Pos, kv => kv.Key)); }