Esempio n. 1
0
 public static IQueryable <ListItem> QueryProjects(this ListItemCollection collection)
 {
     return(collection.Include(project => project.Id,
                               project => project["Title"],
                               project => project["Technology"],
                               project => project["ProjectLink"],
                               project => project["ProjectLinkText"]));
 }
        private IEnumerable <ListItem> LoadItems(List list, string viewXml, List <string> viewFields, params Expression <Func <ListItem, object> >[] properties)
        {
            // Used to resolve 'the query expression is not supported' error loading item with FieldValues...
            // http://www.manvir.net/invalidqueryexpressionexception-the-query-expression-is-not-supported/
            CamlQuery query = new CamlQuery();

            query.ViewXml = viewXml;

            ListItemCollection items = list.GetItems(query);
            List <Expression <Func <ListItem, object> > > listItemExpressions = new List <Expression <Func <ListItem, object> > >(properties);

            foreach (string viewField in viewFields)
            {
                Expression <Func <ListItem, object> > retrieveFiedlDataExpresion = item => item[viewField];
                listItemExpressions.Add(retrieveFiedlDataExpresion);
            }

            IEnumerable <ListItem> resultData = list.Context.LoadQuery(items.Include(listItemExpressions.ToArray()));

            list.Context.ExecuteQuery();

            return(resultData);
        }
Esempio n. 3
0
 public static IQueryable <ListItem> QuerySkills(this ListItemCollection collection)
 {
     return(collection.Include(highlight => highlight.Id,
                               highlight => highlight["SkillName"],
                               highlight => highlight["SkillLevel"]));
 }
Esempio n. 4
0
 public static IQueryable <ListItem> QueryHighlights(this ListItemCollection collection)
 {
     return(collection.Include(highlight => highlight.Id,
                               highlight => highlight["Title"],
                               highlight => highlight["Text"]));
 }