我正在尝试使用LINQ对我从客户端对象模型得到的结果.
var rolesAssignments = context.Web.RoleAssignments; context.Load(rolesAssignments,roles => roles.IncludeWithDefaultProperties(role => role.Member,role => role.RoleDefinitionBindings)); context.ExecuteQuery(); var hasAdmin = rolesAssignments.Select(x => x.RoleDefinitionBindings.Cast<RoleDefinition>().Select(y => y.RoleTypeKind == RoleType.Administrator)).Any();
我得到:
{System.NotSupportedException: Invalid usage of query execution. The query should be executed by using ExecuteQuery method on the client context object.
但是,当我重写这个以使用嵌套foreach循环,它工作正常.