如何使用CSOM获取Task.Parent.Id [英] How to get Task.Parent.Id using CSOM

查看:61
本文介绍了如何使用CSOM获取Task.Parent.Id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从使用CSOM的PublishedTask获取Parent.Id。  原因是... PublishedTask的'Parent'属性始终未初始化。  它永远不会为null,并且它永远不会包含实际值。  因此,我无法获得没有
抛出错误的Parent.Id。


此代码不起作用:

 ProjContext.Load(PublishedProject.Tasks); 
ProjContext.ExecuteQuery();

foreach(PublishedProject.Tasks中的PublishedTask任务)
{
Console.WriteLine(Task.Parent.Id);
}


此代码不起作用:



 ProjContext.Load(PublishedProject.Tasks,t => t.Include(pt => pt.Id, pt => pt.Parent))
ProjContext.Load(PublishedProject.Tasks,t => t.Include(pt => pt.Id,pt => pt.Parent,pt => pt .Parent.Id))


我试过在这里发帖,但他们不知道答案:


https://social.msdn.microsoft.com/Forums/en-US/0ec61bdb-76e7-437e-ad4c-b59c9e6da2e3/publishedtaskparent-is-always-uninitialized?forum=project2010custprog


有人知道如何获得PublishedTask的Parent.ID吗?




< hr>

ScoutwestInc

解决方案

哇,我刚试过这个,你就是是的,如果你"包括",它甚至都不起作用。 pt.Parent.Id。


真正奇怪的是它适用于作业:


projContext.Load(project.Assignments,c => ; c.Include(a => a.Id,a => a.Task.Id,a => a.Resource.Id));


但它没有似乎适用于Parent.Id上的任务。我认为这是一个错误。


获取此数据的另一种方法是通过OData。这可能不太理想,如果您没有在经过身份验证的sharepoint网页上运行此代码,则可能需要处理自己的身份验证,但这是另一个选项,而Microsoft
解决了这个问题。


I cannot get the Parent.Id from a PublishedTask using CSOM.  Reason being... the 'Parent' property of PublishedTask is always uninitialized.  It is never null, and it never contains actual values.  Therefore, I cannot get Parent.Id without throwing an error.

This code does not work:

ProjContext.Load(PublishedProject.Tasks);
ProjContext.ExecuteQuery();

foreach (PublishedTask Task in PublishedProject.Tasks)
{    
    Console.WriteLine(Task.Parent.Id);
}

This code does not work:

ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Id, pt => pt.Parent))
ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Id, pt => pt.Parent, pt => pt.Parent.Id))

I tried posting here, but they did not know the answer:

https://social.msdn.microsoft.com/Forums/en-US/0ec61bdb-76e7-437e-ad4c-b59c9e6da2e3/publishedtaskparent-is-always-uninitialized?forum=project2010custprog

Does anybody know how to get the Parent.ID of a PublishedTask?


ScoutwestInc

解决方案

Wow, I just tried this and you are correct, it does not even work if you "include" pt.Parent.Id.

What is really strange is that it works for assignments:

projContext.Load(project.Assignments, c => c.Include(a => a.Id, a => a.Task.Id, a => a.Resource.Id));

But it does not seem to work for Parent.Id on the Task. I think this is a bug.

The other way to get this data is through OData. That may not be ideal and you may have to deal with rolling your own authentication if you are not running this code on an authenticated sharepoint web page, but that is another option for you while Microsoft addresses this issue.


这篇关于如何使用CSOM获取Task.Parent.Id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆