Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#将Microsoft.Sharepoint.Client.FieldUserValue转换为Microsoft.Sharepoint.Cliend.User_C#_Sharepoint - Fatal编程技术网

C#将Microsoft.Sharepoint.Client.FieldUserValue转换为Microsoft.Sharepoint.Cliend.User

C#将Microsoft.Sharepoint.Client.FieldUserValue转换为Microsoft.Sharepoint.Cliend.User,c#,sharepoint,C#,Sharepoint,好的,我正在使用Caml查询从sharepoint列表检索项目。我通过字段值得到我想要的项循环。我的问题是我需要将FieldUserValue数据类型转换为普通用户数据类型。有一种方法可以从用户处检索FieldUserValue,但不是相反的方法 User Usr; foreach (ListItem item in items) { foreach (var f in item.FieldValues) {

好的,我正在使用Caml查询从sharepoint列表检索项目。我通过字段值得到我想要的项循环。我的问题是我需要将FieldUserValue数据类型转换为普通用户数据类型。有一种方法可以从用户处检索FieldUserValue,但不是相反的方法

 User Usr;


        foreach (ListItem item in items)
        {
            foreach (var f in item.FieldValues)
            {
                if (f.Key == "ColumnTitleofDataTypePersonorGroup")
                {
                    //Error Message
                    Usr = f.Value;
                }
            }

        }
详细的错误信息说 错误2无法将类型“object”隐式转换为“Microsoft.SharePoint.Client.User”。存在显式转换(是否缺少转换?
我想我只是错过了一些显而易见的东西。。
感谢您提前提供的帮助。

以下示例演示了如何从中获取:


以下示例演示如何从中获取:


你能帮我回答这个问题吗
var list = ctx.Web.Lists.GetByTitle(listTitle);
var item = list.GetItemById(itemId);
ctx.Load(item);
ctx.ExecuteQuery();

var author = (Microsoft.SharePoint.Client.FieldUserValue) item["Author"];
var authorUser = ctx.Web.SiteUsers.GetById(author.LookupId);
ctx.Load(authorUser);
ctx.ExecuteQuery();