代码:
//创建用户素材
var collectionUri = new Uri(txtTFS.Text);
var tpc = new TfsTeamProjectCollection(collectionUri);
var workItemStore = tpc.GetService<WorkItemStore>();
var teamProject = workItemStore.Projects[txtSelectedProject.Text];
var typeWorkItem = ConfigurationManager.AppSettings["WorkItemType"];
var workItemType = teamProject.WorkItemTypes[typeWorkItem];
var userStory = new WorkItem(workItemType)
{
Title = "Test Title",
Description = "Test Description",
IterationPath = "xx\\yy\\zz",
AreaPath = "xxx\\yyy\\zzz",
State = "New",
// "AssignedTo" field not populated here...
};
// Save the new user story.
userStory.Save();
如何在创建"AssignedTo"
时以编程方式在TFS
UserStory
字段中设置值?
答案 0 :(得分:2)
只有每个工作项类型上的字段在WorkItem
类上都有自己的属性。
您应该使用WorkItem.Fields
属性来访问任何不属性的字段。
userStory.Fields["System.AssignedTo"].Value = "JJJ";
您无法在对象intialiser语法中使用带有索引器的属性,因此您必须在.Save();