2014-02-17 4 views
7

WorkItemCollectionList<WorkItem>으로 변환하여 dictionary으로 변환 할 수 있습니다. 다음 코드는 지금까지의 :WorkItemCollection을 목록으로 변환하는 방법

var testItemCollectionList = new List<WorkItem>(); 
WorkItemCollection testItemCollection; 
Query query = new Query(project.Store, "Select [Title] From WorkItems", testResults.Select(item => item.TargetId).ToArray()); 
var car = query.BeginQuery(); 
testItemCollection = query.EndQuery(car); 
testItemCollectionList = ???; 
var testItemMapQuery = testItemCollectionList.ToDictionary(w => w, createItemFromQuery); 

답변

6
testItemCollectionList = (from WorkItem mItem in testItemCollection select mItem).ToList(); 
7

IEnumerableReadOnlyList을 통해 구현 WorkItemCollection 때문에, 당신이 직접 다음 .Cast<WorkItem>()을 사용하십시오 Dictionary로 변환 할 수 있어야한다.

var testItemMapQuery = testItemCollection.Cast<WorkItem>() 
             .ToDictionary(w => w, createItemFromQuery); 
관련 문제