linq and rest api in sharepoint
//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的更多相关文章
- SharePoint REST API - 同步SharePoint列表项
博客地址:http://blog.csdn.net/FoxDave 本篇只讲REST服务中的GetListItemChangesSinceToken这个东西.何谓同步呢,你也可以理解为增量变化,即 ...
- [sharepoint]rest api文档库文件上传,下载,拷贝,剪切,删除文件,创建文件夹,修改文件夹属性,删除文件夹,获取文档列表
写在前面 最近对文档库的知识点进行了整理,也就有了这篇文章,当时查找这些接口,并用在实践中,确实废了一些功夫,也为了让更多的人走更少的弯路. 系列文章 sharepoint环境安装过程中几点需要注意的 ...
- Atitit 实现java的linq 以及与stream api的比较
Atitit 实现java的linq 以及与stream api的比较 1.1. Linq 和stream api的关系,以及主要优缺点1 1.2. Linq 与stream api的适用场景1 1. ...
- Using LINQ to SharePoint
LINQ and LINQ Providers LINQ is a feature of the programming languages C# and Microsoft Visual Bas ...
- 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 ...
- sharepoint rest api Add ListItem 报错
Recently, I was trying to create a list item using Rest API on Sharepoint 2013. I got the following ...
- [MSDN] 使用 SharePoint 2013 中的 JavaScript 库代码完成基本操作
MSDN:http://msdn.microsoft.com/zh-cn/library/jj163201.aspx 了解如何编写代码以在 SharePoint 2013 中使用 JavaScript ...
- 在 SharePoint 2010 中访问数据
转:http://blog.banysky.net/?p=81001 数据访问的关键方法有哪些? | 使用查询类 | 使用 SPQuery | 使用 SPSiteDataQuery | 使用 LINQ ...
- 年终巨献 史上最全 ——LINQ to SQL语句
LINQ to SQL语句(1)之Where 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的子句.Where操 ...
随机推荐
- [转]Maintain File Upload Control on Postbacks
本文转自:http://www.ironspeed.com/articles/Maintain%20File%20Upload%20Control/Article.aspx Introduction ...
- Java代码操作Redis的sentinel和Redis的集群Cluster操作
总共四台机器,crxy99,crxy98分别是主节点和从节点. crxy97和crxy96是两个监控此主从架构的sentinel节点. 看代码: import org.junit.Test; im ...
- Java开发的一个简单截屏工具
//源代码 import java.awt.*;import java.awt.datatransfer.DataFlavor;import java.awt.datatransfer.Transfe ...
- 交叉编译lsof for android
Android 自带的那个 lsof 实际上是 toolbox 里的,功能十分单一,除了显示出所有进程的所有打开的文件外就什么都不能做,连说明也没有 :-( 于是为了 htop 用着爽一点,还是自己编 ...
- Swift字典类
在Foundation框架中提供一种字典集合,它是由“键-值”对构成的集合.键集合不能重复,值集合没有特殊要求.键和值集合中的元素可以是任何对象,但是不能是nil.Foundation框架字典类也分为 ...
- JSON解析例子
//解析的东西是数组就用数组接受,是字典就用字典接受 //my.h#ifndef __1_Header_h#define __1_Header_h#define DEBUG 1#define aa 1 ...
- Qt 串口通信
在Qt5之前,串口通信基本依赖于第三方库,下面是我曾接触过的串口通信类库: 名称 语言 平台 QextSerialPort QT C++ Win/Linux http://sourceforge. ...
- 坑爹系列:sizeof运算符
C语言里的sizeof关键字用于返回变量的类型宽度(变量所占的字节个数).例如: #include <stdio.h> int main() { int i = 0; int size = ...
- [java学习笔记]java语言核心----面向对象之构造函数
1.构造函数概念 特点: 函数名与类名相同 不用定义返回值类型 没有具体的返回值 作用: 给对象进行初始化 注意: 默认构造函数 多个构造函数是以重载出现的 一个类中如果 ...
- HTML5之拖放
- Draggable 标签 文件拖放 99年IE5开始,05后所有浏览器支持(除了opera) <li id=be draggable=true ondragstart="star ...