//1.make sure your application using the .net fromwork 3.5
//2.create entity classes using the instruction:spmetal /web:http://sv1:82 /namespace:MyLinq /code:c:\MyLinq.cs,
//and copy the MyLinq.cs file to your project
static void linq()
{
string url = "http://sv1:82";
using (MyLinq.MyLinqDataContext context = new MyLinq.MyLinqDataContext(url))
{ var r = from x in context.PaySlip
where x.名称.Length >
select x;
// select new {x.名称,x.路径,x.文档创建者,x.标题};
Console.WriteLine(r.FirstOrDefault().标题); }
} //1.add a service reference to http://sv1:82/_vti_bin/listdata.svc
static void Rest()
{
string url = "http://sv1:82/_vti_bin/listdata.svc";
ServiceReference1.HomeDataContext h1 = new ServiceReference1.HomeDataContext(new Uri(url));
h1.Credentials = new System.Net.NetworkCredential("administrator", "Abcd1234", "sk");
var list = h1.PaySlip.ToList();
if (list.Count() > )
{
Console.WriteLine(list[].标题);
}
else
{
Console.WriteLine("List is empty");
} }

//client object model
 string url = "http://abc.abc.com.cn/LeaveApplication/";
ClientContext clientContext = new ClientContext(url);
clientContext.Credentials = new System.Net.NetworkCredential("spsadmin", "abc123", "domain");
Site siteCollection = clientContext.Site;
Web site = clientContext.Web;
List list = site.Lists.GetByTitle("Application List");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View/>";
ListItemCollection collection = list.GetItems(camlQuery);
clientContext.Load(list);
clientContext.Load(collection);
clientContext.ExecuteQuery();
Console.WriteLine(collection.Count.ToString()); var item = collection[];
FieldLookupValue o = item["Leave_x0020_Type"] as FieldLookupValue; //FieldLookup fieldLookup = list.Fields.GetByTitle("Leave_x0020_Type") as FieldLookup;
//FieldLookupValue lookUpValue1 = field collection[0]["Leave_x0020_Type"] // userMaintenanceCenterId = lookUpValue1.LookupValue; Console.Read();
        static void ClientModel()
{
string url = "http://sv1:82";
Microsoft.SharePoint.Client.ClientContext context = new Microsoft.SharePoint.Client.ClientContext(url);
var site = context.Web;
context.Load(site);
context.ExecuteQuery();
Console.WriteLine(site.Title);
} //make sure you started the " SharePoint Foundation Search service" on the page "Services on Server"
//reference Microsoft.SharePoint.Search
//http://www.sharepointblues.com/2010/02/15/content-queries-using-sharepoint-enterprise-search-api/
static void fullTeextSqlQuery()
{
string url="http://sv1:82/";
Microsoft.SharePoint.SPSite site = new Microsoft.SharePoint.SPSite(url);
Microsoft.SharePoint.Search.Query.FullTextSqlQuery qry = new Microsoft.SharePoint.Search.Query.FullTextSqlQuery(site);
qry.ResultTypes = Microsoft.SharePoint.Search.Query.ResultType.RelevantResults;
string sql = "select title,author,path from scope() where author='administrator'";
qry.QueryText = "select title from scope()";
var result=qry.Execute();
Console.WriteLine(result.Count.ToString()); }

linq and rest api in sharepoint的更多相关文章

  1. SharePoint REST API - 同步SharePoint列表项

    博客地址:http://blog.csdn.net/FoxDave 本篇只讲REST服务中的GetListItemChangesSinceToken这个东西.何谓同步呢,你也可以理解为增量变化,即 ...

  2. [sharepoint]rest api文档库文件上传,下载,拷贝,剪切,删除文件,创建文件夹,修改文件夹属性,删除文件夹,获取文档列表

    写在前面 最近对文档库的知识点进行了整理,也就有了这篇文章,当时查找这些接口,并用在实践中,确实废了一些功夫,也为了让更多的人走更少的弯路. 系列文章 sharepoint环境安装过程中几点需要注意的 ...

  3. Atitit 实现java的linq 以及与stream api的比较

    Atitit 实现java的linq 以及与stream api的比较 1.1. Linq 和stream api的关系,以及主要优缺点1 1.2. Linq 与stream api的适用场景1 1. ...

  4. Using LINQ to SharePoint

    LINQ and LINQ Providers   LINQ is a feature of the programming languages C# and Microsoft Visual Bas ...

  5. How to Call SharePoint 2013 API Service to Query The Lists

    How to Call SharePoint 2013 API In SharePoint 2013, we can query the list by it owner service, then ...

  6. sharepoint rest api Add ListItem 报错

    Recently, I was trying to create a list item using Rest API on Sharepoint 2013. I got the following ...

  7. [MSDN] 使用 SharePoint 2013 中的 JavaScript 库代码完成基本操作

    MSDN:http://msdn.microsoft.com/zh-cn/library/jj163201.aspx 了解如何编写代码以在 SharePoint 2013 中使用 JavaScript ...

  8. 在 SharePoint 2010 中访问数据

    转:http://blog.banysky.net/?p=81001 数据访问的关键方法有哪些? | 使用查询类 | 使用 SPQuery | 使用 SPSiteDataQuery | 使用 LINQ ...

  9. 年终巨献 史上最全 ——LINQ to SQL语句

    LINQ to SQL语句(1)之Where 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子句.Where操 ...

随机推荐

  1. [BigData]关于Hadoop学习笔记第四天(PPT总结)(一)

    课程安排 Partitioner编程** 自定义排序编程** Combiner编程** 常见的MapReduce算法** ---------------------------加深拓展-------- ...

  2. 初识CSS3之媒体查询(2015年05月31日)

    一.什么是媒体查询 媒体查询是面向不同设备提供不同样式的一种实现方式,它可以为每种类型的用户提供最佳的体验,也是响应式设计的实现方式. 现今每天都有更多的手机和平板电脑问市.消费者能够拥有可想象到的各 ...

  3. JMS - 基本概念

    连接工厂创建连接对象的工厂. 连接客户端与 JMS 服务器之间建立的连接.创建一个或多个会话. 会话创建消息.生产者和消费者,会话是 消息由三部分组成:消息头.消息属性和消息体. 生产者创建和发送消息 ...

  4. 【转载】Apache Kafka监控之Kafka Web Console

    http://www.iteblog.com/archives/1084 Kafka Web Console是一款开源的系统,源码的地址在https://github.com/claudemamo/k ...

  5. 【网络收集】MySql中IS NOT NULL与!=NULL的区别

    在mysql中,筛选非空的时候经常会用到is not null和!=null,这两种方法单从字面上来看感觉是差不多的,其实如果去运行一下试试的话差别会很大!为什么会出现这种情况呢?null 表示什么也 ...

  6. 【SQLServer】将Job运行结果发送电子邮件通知用户

    SQLServer2005/2008数据库邮件功能: 1. 启用数据库邮件功能:打开SQL Server 2005 外围应用配置器,选择“功能的外围应用配置器”,选择“数据库邮件”,勾选“启用数据库邮 ...

  7. OpenGL7-2-快速绘制

    代码下载 #include "CELLWinApp.hpp"#include <gl/GLU.h>#include <assert.h>#include & ...

  8. Spring boot 1.3.5 RELEASE 官方文档中文翻译--Part2:新手入门

    Part II. 新手入门 如果你刚刚开始学习Spring boot或"普通"的Spring,这部分非常适合你!在这里,我们回答了最基础的"什么是?".&quo ...

  9. c# winform 点菜宝接口demo程序

    前几天写了一篇关于c#调用 win32API的文章,有同学对点菜宝接口感兴趣,所以就把写的demo程序共享出来,大家一起讨论改进,so放百度云地址: 百度云下载地址

  10. 算法 replace,replace_copy,back_inserter

    replace (list.begin(), list.end(), , ); // replace any elements with value of 0 by 42 replace算法对输入序列 ...