を与えられIEnumerable<KeyValuePair<string,string>>
て、私はlinqを使用して値を1つの文字列に連結しようとしています。
私の試み:
string path = attributes.Aggregate((current, next) => "@" + current.Key + "=" + current.Value + " and @" + next.Key + "=" + next.Value);
これにより、エラーが発生します。
string
式タイプ' 'を戻りタイプ''にKeyValuePair<string,string>
変換できません
linqでこれを行うためのより効率的な方法はありますか?
完全な方法...
public IEnumerable<XmlNode> GetNodes(IEnumerable<KeyValuePair<string,string>> attributes) {
StateInfoXmlDocument stateInfoXmlDocument = new StateInfoXmlDocument();
string path = attributes.Aggregate((current, next) => "@" + current.Key + "=" + current.Value + " and @" + next.Key + "=" + next.Value);
string schoolTypeXmlPath = string.Format(SCHOOL_TYPE_XML_PATH, path);
return stateInfoXmlDocument.SelectNodes(schoolTypeXmlPath).Cast<XmlNode>().Distinct();
}