//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. 转:android git开源项目列表

    1. 知乎的合集说明 https://www.zhihu.com/question/19804692 2. http://p.codekk.com/

  2. 10秒视频转局部GIF动画

    10秒视频转局部GIF动画,微软出品的一款精致小软件. 百度云盘:http://pan.baidu.com/s/1i3SARfn

  3. DataTables手动带参数提交至服务器

    一:参数传递及接收 JavaScript: 黄背景部分为参数传递关键 <script type="text/javascript"> var table; var de ...

  4. replace替换语句

    t_sql语句:replace替换语句:update 表名 set 列名=REPLACE(列名,'替换的数据','替换后的数据')

  5. HDOJ2020绝对值排序

    绝对值排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  6. android opencv 人脸检测

    转载自http://blog.csdn.net/jesse__zhong/article/details/24889709 .......省略包 public class Staticdetectio ...

  7. JavaScript之可运行按钮

    看到好多大神都写了像这种在页面"可运行"的Javascript脚本,感觉很好奇,所以我今天也试着写了一个. 自从有了这个"可运行"按钮,好多代码就再也不以图片的 ...

  8. SharePoint Server 2013介绍v2

    SharePoint Server 2013介绍v2 http://wenku.baidu.com/link?url=rNYYoDmHcXmqhzOeA1sln5cS2xcnABYycBuz8Z4Oq ...

  9. OC2-重写

    // // Dog.h // OC2-重写 // // Created by qianfeng on 15/6/17. // Copyright (c) 2015年 qianfeng. All rig ...

  10. (转) 读取xml文件转成List<T>对象的两种方法

    读取xml文件,是项目中经常要用到的,所以就总结一下,最近项目中用到的读取xml文件并且转成List<T>对象的方法,加上自己知道的另一种实现方法. 就以一个简单的xml做例子. xml格 ...