c# - 从 Project Online 获取 ProjectSiteUrl 不起作用
问题描述
我编写了以下代码以ProjectSiteUrl
从 Project Online 中发布的项目中获取属性
using (ProjectContext projContext = new ProjectContext(pwaUrl))
{
using (SecureString securePassword = new SecureString())
{
Helper.GetSecurePassword(projContext, securePassword, emailID, password);
for (int i = 0; i < listGuid.Count; i++)
{
#region Load Project
string spoGuid = listGuid[i].ProjectGuid;
if (!string.IsNullOrEmpty(spoGuid))
{
Guid id = Guid.Parse(spoGuid);
var projBlk = projContext.LoadQuery(
projContext.Projects
.Where(p =>
p.Id == id
)
.Include(p => p.Id,
p => p.Tasks,
p => p.TaskLinks,
p => p.ScheduledFromStart,
p => p.ProjectSiteUrl,
p => p.Name,
p => p.IncludeCustomFields,
p => p.IncludeCustomFields.CustomFields,
P => P.IncludeCustomFields.CustomFields.IncludeWithDefaultProperties(
lu => lu.LookupTable,
lu => lu.LookupEntries,
lu => lu.LookupEntries.IncludeWithDefaultProperties(
entry => entry.FullValue,
entry => entry.InternalName)
)
)
);
projContext.ExecuteQuery();
poFieldValues.Add(LoadProjectsinPO(projBlk, projContext));
}
#endregion
//if (i > 5)
//{
// break;
//}
if (i % 5 == 0)
{
Thread.Sleep(sleepDelay);
}
}
}
}
在尝试访问我得到的 ProjectSiteUrl 属性时null
。我曾经得到正确的 ProjectSiteUrl,但在过去的几周里,我得到了空值。代码没有变化。
我们在 Project Online 中访问此属性的方式是否发生了变化?
解决方案
我已经修改了加载查询中加载属性的顺序,ProjectSiteUrl
现在加载正常。不知道为什么它正在工作。如果有人解释这一点,将不胜感激。
var projBlk = projContext.LoadQuery(
projContext.Projects
.Where(p =>
p.Id == id
)
.Include(p => p.Id,
p => p.ProjectSiteUrl, // Moved ProjectSiteUrl as second loading parameter.
p => p.Tasks,
p => p.TaskLinks,
p => p.ScheduledFromStart,
p => p.Name,
p => p.IncludeCustomFields,
p => p.IncludeCustomFields.CustomFields,
P => P.IncludeCustomFields.CustomFields.IncludeWithDefaultProperties(
lu => lu.LookupTable,
lu => lu.LookupEntries,
lu => lu.LookupEntries.IncludeWithDefaultProperties(
entry => entry.FullValue,
entry => entry.InternalName)
)
)
);
推荐阅读
- google-app-engine - GAE Go 运行时 1.11 需要比运行时 1.9 更多的实例。这么常见吗?
- database - 为什么有些键值数据存储拒绝表/桶的概念?
- javascript - 有没有办法防止排他的水平/垂直平移/滚动,即栏杆?
- c# - “System.Web.UI.Page”不包含“DataItem”的定义
- flutter - 如何在颤动中更改文本字段的晦涩字符?
- javascript - Map.get() 在异步函数中返回未定义
- python - 用python编辑文本文件中的字典
- python - Django 2.2.5 的密码重置问题
- python - Python Pandas 使用先例行值更新行中的值
- python - 在 numpy 数组中逐元素应用操作