惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
罗磊的独立博客
博客园 - 聂微东
博客园_首页
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
Jina AI
Jina AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
量子位
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
月光博客
月光博客
T
The Exploit Database - CXSecurity.com
Google DeepMind News
Google DeepMind News
H
Help Net Security
O
OpenAI News
Blog — PlanetScale
Blog — PlanetScale
S
Security Affairs
S
Security @ Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
T
The Blog of Author Tim Ferriss
AI
AI
MongoDB | Blog
MongoDB | Blog
G
Google Developers Blog
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
Hugging Face - Blog
Hugging Face - Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Schneier on Security
Cloudbric
Cloudbric
H
Heimdal Security Blog
J
Java Code Geeks
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
I
Intezer
GbyAI
GbyAI

博客园 - 范文轩

Sharepoint中的Feature Stapling功能 SharePoint 2010中的WebProvisioned Event Handler 如何向列表中添加数据值(开发篇) 如何向列表中添加数据值(管理员篇) 在SharePoint 2010中动态加载Visio Web Part 使用编程的方式来启动SharePoint的工作流 InfoPath 2010调用REST的一个小应用 SharePoint 2010 WSP包部署过程中究竟发生什么? 如何查看SharePoint 2010的CU版本 SharePoint 2010多语言包的安装 在SharePoint 2010中使用Linq时候,请注意特殊字符 自定义ASP.NET WebApplication中调用SharePoint2010的对象 在Infopath 2010中调用Web Service 谈谈SharePoint 2010的客户端对象模型的性能问题 给Document Set里面添加文件夹 给Chart Web Part 添加过滤功能 SharePoint 2010的Form认证的用户注册功能 SharePoint 调查列表的自定义错误页面 Reporting Services 2008 and SharePoint 2010
如何向列表中添加数据值(开发篇补充REST)
范文轩 · 2011-08-13 · via 博客园 - 范文轩

SharePoint 2010中增加了对ADO.NET Service的支持。我们可以通过REST的方式来添加,查询或者更新数据。这篇文章,我将尝试使用REST的方式来查询,并且添加一条记录。

准备工作:开始使用代码之前,记得要添加对 http://servername/_vti_bin/listdata.svc 服务的引用。我是引用之后,将其命名为“ListDataSR”, 一下是详细代码。(我是在控制台程序中运行这段代码的)

ListDataSR.SPFLearnDataContext ctx = 
            new ListDataSR.SPFLearnDataContext( new Uri("http://servername/_vti_bin/listdata.svc"));

public void AddNewItem()
{
    ctx.Credentials = CredentialCache.DefaultCredentials;
    ListDataSR.JobsItem newJob = new JobsItem();
    newJob.Title = "SharePoint QA";
    newJob.JobDescription = "QA in SharePoint project";
    newJob.CityValue = "Shanghai";
    newJob.DueDate = DateTime.Now.AddDays(12);
    newJob.JobRequirementId = 2;
    newJob.ManagerId = 1;

    ctx.AddToJobs(newJob);
    ctx.SaveChanges();
}

public void GetItems()
{
    ctx.Credentials = CredentialCache.DefaultCredentials;
    var jobsInShanghai = from q in ctx.Jobs
                         where q.CityValue =="Shanghai"
                         select q;
    foreach (var item in jobsInShanghai)
    {
        Console.WriteLine(
            "Job Title: {0}; Due Date{1}; City:{2}",
            item.Title,
            item.DueDate,
            item.CityValue);
    }                       
}

本系列三篇文章对自己是一个积累,总结。希望对有需要的朋友能有所帮助。