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操 ...
随机推荐
- 【转】istringstream、ostringstream、stringstream 类介绍 .
http://www.cnblogs.com/gamesky/archive/2013/01/09/2852356.html 好吧,懒死我算了
- Java Classloader原理分析
类的加载过程指通过一个类的全限定名来获取描述此类的二进制字节流,并将其转化为方法区的数据结构,进而生成一个java.lang.Class对象作为方法区这个类各种数据访问的入口.这个过程通过Jav ...
- (转)工作之路---记录LZ如何在两年半的时间内升为PM
原文地址:http://www.cnblogs.com/zuoxiaolong/p/life31.html 引言 之前的伪PM纠结之路已经渐渐结束,LZ也终于正式爬上了PM的位置,对于LZ来说,这个时 ...
- javascript基础知识--函数定义
函数声明式 function funname( 参数 ){ ...执行的代码 } 声明式的函数并不会马上执行,需要我们调用才会执行:funname(); * 分号是用来分隔可执行JavaScript语 ...
- Rust 学习 0
安装Rust 后,本地有文档: file:///usr/local/share/doc/rust/html/index.html file:///usr/local/share/doc/rust/ht ...
- 【AngularJs】---Error: [$injector:modulerr] Failed to instantiate module starter.services
[遇到问题解决问题,原谅我这个菜鸟] 加了services angular.module('starter', ['ionic', 'starter.controllers', 'starter.se ...
- Ubuntu中wine安装的程序如何卸载
很多朋友尝试在Ubuntu中用wine安装exe格式的应用程序,但经常遇到装完之后启动程序就崩溃.或者根本无法启动.无法使用的情况,于是想立即把安装的程序卸载,可是在wine中却找不到卸载exe软件的 ...
- 关于ios对rtsp格式的流媒体支持的一些官方说明
ios明确不支持rtsp格式的流媒体,基于rtsp/rtp对通用性和防炎墙以及需要开新端口等额外影响稳定性和通用性的原因. 而对http流的视频支持是最好的.虽然有第三方的方式配合ffmpeg库,实现 ...
- 你不知道的JSON的高效率用法
1.JSON JSON是JavaScript Object Notation的缩写,是JavaScript标准的一个子集.官方Android API已经内置支持读写JSON数据.这种格式非常适合表示不 ...
- UML——动态建模