查看QueryHistory
的{{1}}方法重载:
似乎有些重载会返回Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer
和其他人返回System.Collections.Generic.IEnumerable<Changeset>
。
有一种简单的方法可以将System.Collections.IEnumerable
(包含System.Collections.IEnumerable
项)转换为Changeset
吗?
答案 0 :(得分:1)
如果您确定该集合只包含ChangeSet
项,则可以使用Linq扩展方法Cast()
:
IEnumerable myCollection = ...
IEnumerable<ChangeSet> myGenericCollection = myCollection.Cast<ChangeSet>();
如果您不完全确定该集合仅包含ChangeSet
,则可以使用其他Linq扩展方法OfType()
对其进行过滤:
IEnumerable myCollection = ...
IEnumerable<ChangeSet> myGenericCollection = myCollection.OfType<ChangeSet>();