当前位置: 首页>>代码示例>>C#>>正文


C# ClientContext.LoadQuery方法代码示例

本文整理汇总了C#中ClientContext.LoadQuery方法的典型用法代码示例。如果您正苦于以下问题:C# ClientContext.LoadQuery方法的具体用法?C# ClientContext.LoadQuery怎么用?C# ClientContext.LoadQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClientContext的用法示例。


在下文中一共展示了ClientContext.LoadQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTypedFields

        protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
        {
            var typedFields = context.LoadQuery(items.Where(i => i.TypeAsString == BuiltInFieldTypes.TaxonomyFieldType));
            context.ExecuteQueryWithTrace();

            var result = new List<Field>();

            result.AddRange(typedFields);

            typedFields = context.LoadQuery(items.Where(i => i.TypeAsString == BuiltInFieldTypes.TaxonomyFieldTypeMulti));
            context.ExecuteQueryWithTrace();

            result.AddRange(typedFields);

            return result;
        }
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:16,代码来源:TaxonomyFieldReverseHandler.cs

示例2: GetTypedFields

        protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
        {
            var typedFields = context.LoadQuery(items.Where(i => i.TypeAsString == BuiltInPublishingFieldTypes.HTML));
            context.ExecuteQueryWithTrace();

            return typedFields;
        }
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:7,代码来源:HTMLFieldReverseHandler.cs

示例3: GetTypedFields

        protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
        {
            var typedFields = context.LoadQuery(items.Where(i => i.FieldTypeKind == FieldType.User));
            context.ExecuteQueryWithTrace();

            return typedFields;
        }
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:7,代码来源:UserFieldReverseHandler.cs

示例4: GetTypedFields

        protected override IEnumerable<Field> GetTypedFields(ClientContext context, FieldCollection items)
        {
            var typedFields = context.LoadQuery(
                items.Where(i => i.FieldTypeKind == FieldType.Number)
                     .IncludeWithDefaultProperties());

            context.ExecuteQueryWithTrace();

            return typedFields;
        }
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:10,代码来源:NumberFieldReverseHandler.cs

示例5: GetWebLists

        public static IEnumerable<List> GetWebLists(ClientContext context)
        {
            var retVal =
                context.LoadQuery(
                    context.Web.Lists.Include(l => l.Id, l => l.RootFolder, l => l.RootFolder.Name,
                        l => l.RootFolder.ContentTypeOrder, l => l.Fields, l => l.ContentTypes));
            context.ExecuteQuery();

            return retVal;
        }
开发者ID:tarurar,项目名称:TaxoMotor.Client,代码行数:10,代码来源:WebHelpers.cs

示例6: GetWebList

        public static List GetWebList(ClientContext context, string listName)
        {
            var listCollection =
                context.LoadQuery(
                    context.Web.Lists.Where(l => l.RootFolder.Name == listName)
                        .Include(l => l.Id, l => l.RootFolder, l => l.RootFolder.Name,
                            l => l.RootFolder.ContentTypeOrder, l => l.Fields, l => l.ContentTypes));
            context.ExecuteQuery();

            return listCollection.FirstOrDefault();
        }
开发者ID:tarurar,项目名称:TaxoMotor.Client,代码行数:11,代码来源:WebHelpers.cs

示例7: VerifyDocLib

        // This function will be triggered based on the schedule you have set for this WebJob
        public static void VerifyDocLib()
        {
            var url = ConfigurationManager.AppSettings["SpUrl"].ToString();
            var user = ConfigurationManager.AppSettings["SpUserName"].ToString();
            var pw = ConfigurationManager.AppSettings["SpPassword"].ToString();
            using (PnPMonitoredScope p = new PnPMonitoredScope())
            {
                p.LogInfo("Gathering connect info from web.config");
                p.LogInfo("SharePoint url is " + url);
                p.LogInfo("SharePoint user is " + user);
                try
                {
                    ClientContext cc = new ClientContext(url);
                    cc.AuthenticationMode = ClientAuthenticationMode.Default;
                    cc.Credentials = new SharePointOnlineCredentials(user, GetPassword(pw));
                    using (cc)
                    {
                        if (cc != null)
                        {
                            string listName = "Site Pages";
                            p.LogInfo("This is what a Monitored Scope log entry looks like in PNP, more to come as we try to validate a lists existence.");
                            p.LogInfo("Connect to Sharepoint");
                            ListCollection lists = cc.Web.Lists;
                            IEnumerable<List> results = cc.LoadQuery<List>(lists.Where(lst => lst.Title == listName));
                            p.LogInfo("Executing query to find the Site Pages library");
                            cc.ExecuteQuery();
                            p.LogInfo("Query Executed successfully.");
                            List list = results.FirstOrDefault();
                            if (list == null)
                            {
                                p.LogError("Site Pages library not found.");
                            }
                            else
                            {
                                p.LogInfo("Site Pages library found.");

                                ListItemCollection items = list.GetItems(new CamlQuery());
                                cc.Load(items, itms => itms.Include(item => item.DisplayName));
                                cc.ExecuteQueryRetry();
                                string pgs = "These pages were found, " + string.Join(", ", items.Select(x => x.DisplayName));
                                p.LogInfo(pgs);
                            }
                        }
                    }

                }
                catch (System.Exception ex)
                {
                    p.LogInfo("We had a problem: " + ex.Message);
                }
            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:53,代码来源:Functions.cs

示例8: GetSiteLists

        private static IEnumerable<List> GetSiteLists(string siteUrl)
        {
            // TODO possible context should be have the one instance for each site
            using (var context = new ClientContext(siteUrl))
            {
                var query = from lists in context.Web.Lists
                            where !lists.Hidden
                            select lists;
                var siteLists = context.LoadQuery(query);
                context.ExecuteQuery();

                return siteLists;
            }
        }
开发者ID:ivankozyrev,项目名称:fls-internal-portal,代码行数:14,代码来源:AvailableSiteListsUserControl.ascx.cs

示例9: GetRoleAssignmentByPrincipal

 public static SPDGRoleAssignment GetRoleAssignmentByPrincipal(SecurableObject securableObject, ClientContext context, SPDGPrincipal principal)
 {
     var principalId = principal.ID;
     var roleAss = securableObject.RoleAssignments.Where(x => x.PrincipalId == principalId).Include(x => x.RoleDefinitionBindings, x => x.Member, x => x.PrincipalId);
     var results = context.LoadQuery(roleAss);
     context.ExecuteQuery();
     if (results.Any())
     {
         return new SPDGClientRoleAssignment(results.First(), principal, results.First().RoleDefinitionBindings.Select(x => new SPDGClientRoleDefinition(x)));
     }
     else
     {
         return null;
     }
 }
开发者ID:Acceleratio,项目名称:SPDG,代码行数:15,代码来源:ClientRoleAssignmentHelper.cs

示例10: GetListByTitle

        /// <summary>
        /// Check list exsited or not in site
        /// </summary>
        /// <param name="clientContext"></param>
        /// <param name="listTitle"></param>
        /// <returns>List</returns>
        private static List GetListByTitle(ClientContext clientContext, String listTitle)
        {
            List existingList;

            Web web = clientContext.Web;
            ListCollection lists = web.Lists;

            IEnumerable<List> existingLists = clientContext.LoadQuery(
                    lists.Where(
                    list => list.Title == listTitle)
                    );
            clientContext.ExecuteQuery();

            existingList = existingLists.FirstOrDefault();

            return existingList;
        }
开发者ID:nganbui,项目名称:SP,代码行数:23,代码来源:Program.cs

示例11: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            ClientContext context = new ClientContext("http://intranet.contoso.com");

            Web site = context.Web;
            context.Load(site, osite => osite.Title);
            context.ExecuteQuery();

            Title = site.Title;

            ListCollection lists = site.Lists;
            IEnumerable<SP.List> listsCollection =
                context.LoadQuery(lists.Include(l => l.Title, l => l.Id));
            context.ExecuteQuery();

            ListBox1.ItemsSource = listsCollection;
            ListBox1.DisplayMemberPath = "Title";
        }
开发者ID:sreekanth642,项目名称:sp2010_lab,代码行数:20,代码来源:MainWindow.xaml.cs

示例12: CheckFeatureActivation

        public static bool CheckFeatureActivation(ClientContext context, Guid featureId, FeatureScope scope)
        {
            FeatureCollection features = null;
            switch (scope)
            {
                case FeatureScope.Web:
                    features = context.Web.Features;
                    break;
                case FeatureScope.Site:
                    features = context.Site.Features;
                    break;
                default:
                    throw new NotImplementedException();

            }
            var featureCollection = context.LoadQuery(features.Include(f => f.DefinitionId));
            context.ExecuteQuery();

            return featureCollection.Any(f => f.DefinitionId.Equals(featureId));
        }
开发者ID:tarurar,项目名称:TaxoMotor.Client,代码行数:20,代码来源:WebHelpers.cs

示例13: GetLibraries

        public static List<SPLibrary> GetLibraries(string webUrl)
        {
            var context = new ClientContext(webUrl);
            var web = context.Web;
            context.Load(web, w => w.Title, w => w.Description);
            var query = from list in web.Lists.Include(l => l.Title, l => l.Id)
                        where list.Hidden == false && list.BaseType == BaseType.DocumentLibrary
                        select list;
            var lists = context.LoadQuery(query);
            context.ExecuteQuery();

            var libraries = new List<SPLibrary>();
            foreach (var list in lists)
                libraries.Add(new SPLibrary()
                {
                    Title = list.Title,
                    Id = list.Id,
                    WebUrl = webUrl
                });
            return libraries;
        }
开发者ID:beachandbytes,项目名称:GorillaDocs,代码行数:21,代码来源:SPHelper.cs

示例14: GetContentType

        /// <summary>
        /// Returns content type associated with the list.
        /// </summary>
        /// <param name="list">List object</param>
        /// <param name="clientContext">Client Context object</param>
        /// <returns>Content type object</returns>
        internal static ContentType GetContentType(List list, ClientContext clientContext)
        {
            ContentType targetDocumentSetContentType = null;
            ContentTypeCollection listContentTypes = null;
            try
            {
                listContentTypes = list.ContentTypes;
                clientContext.Load(
                                                   listContentTypes,
                                                   types => types.Include(
                                                  type => type.Id,
                                                  type => type.Name,
                                                  type => type.Parent));

                var result = clientContext.LoadQuery(listContentTypes.Where(c => c.Name == ConstantStrings.OneDriveDocumentContentType));
                clientContext.ExecuteQuery();
                targetDocumentSetContentType = result.FirstOrDefault();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
            }
            return targetDocumentSetContentType;
        }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:30,代码来源:BriefcaseContentTypeHelperFunctions.cs

示例15: DoWork

        private static void DoWork()
        {
            Console.WriteLine();
            Console.WriteLine("Url: " + url);
            Console.WriteLine("User Name: " + userName);
            Console.WriteLine("List Name: " + listName);
            Console.WriteLine();
            try
            {

                Console.WriteLine(string.Format("Connecting to {0}", url));
                Console.WriteLine();
                ClientContext cc = new ClientContext(url);
                cc.AuthenticationMode = ClientAuthenticationMode.Default;
                cc.Credentials = new SharePointOnlineCredentials(userName, password);

                ListCollection lists = cc.Web.Lists;
                IEnumerable<List> results = cc.LoadQuery<List>(lists.Where(lst => lst.Title == listName));
                cc.ExecuteQuery();
                List list = results.FirstOrDefault();
                if (list == null)
                {

                    Console.WriteLine("A list named \"{0}\" does not exist. Press any key to exit...", listName);
                    Console.ReadKey();
                    return;
                }

                nextRunTime = DateTime.Now;

                ChangeQuery cq = new ChangeQuery(false, false);
                cq.Item = true;
                cq.DeleteObject = true;
                cq.Add = true;
                cq.Update = true;
                
                // Initially set the ChangeTokenStart to 2 days ago so we don't go off and grab every item from the list since the day it was created.
                // The format of the string is semicolon delimited with the following pieces of information in order
                // Version number 
                // A number indicating the change scope: 0 – Content Database, 1 – site collection, 2 – site, 3 – list. 
                // GUID representing the scope ID of the change token
                // Time (in UTC) when the change occurred
                // Number of the change relative to other changes
                cq.ChangeTokenStart = new ChangeToken();
                cq.ChangeTokenStart.StringValue = string.Format("1;3;{0};{1};-1", list.Id.ToString(), DateTime.Now.AddDays(-2).ToUniversalTime().Ticks.ToString());

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(string.Format("Ctrl+c to terminate. Press \"r\" key to force run without waiting {0} seconds.", WaitSeconds));
                Console.WriteLine();
                Console.ResetColor();
                do
                {
                    do
                    {
                        if (Console.KeyAvailable && Console.ReadKey(true).KeyChar == 'r') { break; }
                    }
                    while (nextRunTime > DateTime.Now);

                    Console.WriteLine(string.Format("Looking for items modified after {0} UTC", GetDateStringFromChangeToken(cq.ChangeTokenStart)));

                    
                    ChangeCollection coll = list.GetChanges(cq);
                    cc.Load(coll);
                    cc.ExecuteQuery();


                    DisplayChanges(coll, cq.ChangeTokenStart);
                    // if we find any changes to the list take the last change and use the ChangeToken as the start time for our next query.
                    // The ChangeToken will contain the Date/time of the last change to any item in the list.
                    cq.ChangeTokenStart = coll.Count > 0 ? coll.Last().ChangeToken : cq.ChangeTokenStart;

                    nextRunTime = DateTime.Now.AddSeconds(WaitSeconds);

                } while (true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();

            }
        }
开发者ID:CherifSy,项目名称:PnP,代码行数:83,代码来源:Program.cs


注:本文中的ClientContext.LoadQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。