linq and rest api in sharepoint

时间:2022-12-12 10:14:21
  //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. &lbrack;sharepoint&rsqb;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. &lbrack;MSDN&rsqb; 使用 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. 最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目

    最近帮客户实施的基于SQL Server AlwaysOn跨机房切换项目 最近一个来自重庆的客户找到走起君,客户的业务是做移动互联网支付,是微信支付收单渠道合作伙伴,数据库里存储的是支付流水和交易流水 ...

  2. POJ1080Human Gene Functions(LCS变形)

    题目链接 题目:给出两个串,每匹配一种有一种权值,求权值最大的匹配串 就是 最长公共子序列的 的思想: 首先对于 i 和 j 来比较, 一种情况是i和j匹配,此时 dp[i][j] = dp[i - ...

  3. iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(二)

    一.实现效果             二.实现代码 1.数据模型部分 YYQQGroupModel.h文件 // // YYQQGroupModel.h // 02-QQ好友列表(基本数据的加载) / ...

  4. hdu 5821 &lpar;贪心排序&rpar; Ball

    题目:这里 题意:T组数据,两个长度都为n的数组,有m次操作,操作是对a数组而言,每次操作给一个区间范围l,r,可以将这个区间内的数任意交换顺序,问经过m次操作后, 是否可以将a数组变为b数组. 输入 ...

  5. Linux如何统计进程的CPU利用率

    1.0 概述 在Linux的/proc文件系统,可以看到自启动时候开始,所有CPU消耗的时间片:对于个进程,也可以看到进程消耗的时间片.这是一个累计值,可以"非阻塞"的输出.获得一 ...

  6. ZigBee2006&comma;2007,pro各个版本的区别

    文章转载自http://home.eeworld.com.cn/my/space-uid-361439-blogid-224722.html

  7. android 程序打开第三方程序

    因为在开发过程中需要开启扫描第三方程序,并且点击启动的效果,所以对这个功能进行了实现,并且分享出来个大家. 之前看到网上说需要获取包名和类名,然后通过  intent 才能打开这个程序,其实不必要这样 ...

  8. json概述及python处理json等数据类型

    <一,概念> 序列化(Serialization):将对象的状态信息转换为可以存储或可以通过网络传输的过程,传输的格式可以是JSON.XML等.反序列化(deserialization): ...

  9. jsom快速入门

    JSON JSON: JavaScript Object Notation(JavaScript 对象表示法) JSON 是存储和交换文本信息的语法,具有自我描述性.类似 XML, 但比 XML 更小 ...

  10. linux 安装配置 sublime 进行 python 开发

    1. 下载sublime 地址:http://www.sublimetext.com/3 2. 解压出来,将sublime_text_3 文件夹的名字改为 sublime_text , 然后将 sub ...