SharePoint, LINQ иOpen Data Protocol<br />Vitaly Baum<br />Senior SharePoint Developer @ Conteq <br />Активный участник гр...
План выступления<br />LINQ to SharePoint 2010<br />Open Data Protocol<br />
LINQ to SharePoint<br />
Преимущества LINQ<br />Строгая типизация<br />Запросы к реляционным данным в строго-типизированной форме<br />Компилятор п...
LINQ to SharePoint<br />SPMetal<br />Генерирует DataContext<br />SPMetal /web:http://ContosoServer/Marketing /code:Marketi...
LINQ to SharePoint<br />Недостатки<br />Преобразуется в CAML<br />Не все операторы реализованы<br />Двухэтапные запросы<br...
Mapping<br />internal partial class OrganisationSiteDataContext     : Microsoft.SharePoint.Linq.DataContext{}<br />[Conten...
ICostumMapping<br />public partial class Project : ICustomMapping<br />{   <br />[CustomMapping(Columns = new String[] { «...
SPMetal<br />ImtechSPMetalDefinition Extension<br />
LINQ to SharePoint<br />Демо<br />
Open Data Protocol<br />Открытый доступ к данным<br />Открытыеформаты данных<br />Унифицированная форма запросов<br />
Open Data Protocol<br />Открытый доступ к данным<br />HTTP<br />Открытыеформаты данных<br />AtomPub, JSON<br />Унифицирова...
Open Data Protocol<br />Уровень абстракции<br />Широкого доступа<br />Унифицированного доступа<br />Простого доступа<br />
Open Data Protocol<br />Потребители<br />Браузеры<br />OData Explorer<br />Excel 2010 (PowerPivot)<br />LinQPad<br />Visua...
Open Data Protocol<br />http://services.odata.org/OData/OData.svc/<br /><service xml:base="http://services.odata.org/OData...
Open Data Protocol<br />http://services.odata.org/OData/OData.svc/Products<br /><?xml version="1.0" encoding="windows-1251...
Open Data Protocol<br />http://services.odata.org/OData/OData.svc/Products(4)<br /><?xml version="1.0" encoding="windows-1...
Open Data Protocol<br />Типы данных<br />Null<br />Binary<br />Boolean<br />Byte<br />DateTime<br />Decimal<br />Double<br...
Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Products<br /><feed xml:base="http://localhost:8080/...
Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Products<br /><feed xml:base="http://localhost:8080/...
Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Description<br /><Description xmlns="http://schemas....
Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Description/$value<br />Sweet and savory sauces, rel...
Open Data Protocol<br />http://localhost:8080/owind.svc/Categories/$count<br />8<br />
Open Data Protocol<br />http://localhost:53211/owind.svc/Categories(4)/$links/Products<br /><links xmlns="http://schemas.m...
Open Data Protocol<br />http://localhost:8080/owind.svc/Categories?$orderby=CategoryName desc&$top=4<br />http://localhost...
Open Data Protocol<br /><html><br /><head><br />    <title>OData JSON Test</title><br />    <script src="/Scripts/jquery-1...
Open Data Protocol<br />Объявлять функции<br />Выдавать данные в JSON<br />Наслаждаться жизнью<br />
Open Data Protocol<br />Поставщики<br />SharePoint 2010<br />IBM WebSphere<br />SQL Azure<br />Azure Table Storage<br />SQ...
Open Data Protocol<br />Поставщики<br />Facebook<br />Netflix<br />Pluralsight<br />Stack Overflow<br />Codename Dallas<br...
Browser, Visual Studio, Python<br />Демо<br />
Готовим OData<br />
Готовим OData<br />Парочка IQueryable<T><br />ADO.NET Data Services v1.5<br />Немного желания<br />
Готовим ODataEntity Framework, LINQ to SQL<br />public class ProductService : DataService<ProductEntities><br />{<br />pub...
Готовим ODataReflection Provider<br />public class MyDataSource<br />{ <br />    public IQueryable<Product> Products { get...
Готовим OData<br />Демо<br />
OData в SharePoint<br />
SharePoint OData<br />Content database<br />SharePoint Data<br />SharePoint<br />LINQ to SharePoint<br />ListData.svc<br /...
SharePoint OData<br />Операции и HTTP действия<br />Получение данных GET<br />Создание записи POST<br />Изменение записи...
OData в SharePoint<br />Демо<br />
Vitaly Baum<br />http://butaji.ru<br />vbaum@live.com<br />
Ресурсы<br />http://sharepoint.microsoft.com/<br />http://odata.org<br />http://msdn.microsoft.com/en-us/library/ff478141....
Upcoming SlideShare
Loading in...5
×

SharePoint, LINQ, OData

1,578

Published on

Презентация с семинара "LINQ'остроительство и SharePoint"

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,578
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

SharePoint, LINQ, OData

  1. 1. SharePoint, LINQ иOpen Data Protocol<br />Vitaly Baum<br />Senior SharePoint Developer @ Conteq <br />Активный участник групп разработчиков в Санкт-Петербурге и Москве, подкастер и блоггер<br />http://butaji.ru<br />
  2. 2. План выступления<br />LINQ to SharePoint 2010<br />Open Data Protocol<br />
  3. 3. LINQ to SharePoint<br />
  4. 4. Преимущества LINQ<br />Строгая типизация<br />Запросы к реляционным данным в строго-типизированной форме<br />Компилятор проверит ошибки в запросах<br />IntelliSense<br />Унифицированный путь получения данных из любого источника<br />
  5. 5. LINQ to SharePoint<br />SPMetal<br />Генерирует DataContext<br />SPMetal /web:http://ContosoServer/Marketing /code:MarketingSite.cs <br />
  6. 6. LINQ to SharePoint<br />Недостатки<br />Преобразуется в CAML<br />Не все операторы реализованы<br />Двухэтапные запросы<br />Аггрегирующие запросы<br />SPSiteDataQuery<br />
  7. 7. Mapping<br />internal partial class OrganisationSiteDataContext : Microsoft.SharePoint.Linq.DataContext{}<br />[ContentType(Name = "Employee")]<br />public partial class Employee<br />{ <br />[Column(Name="ID", IsId=true, ReadOnly=true, FieldType="Counter")] <br />public int Id {get; set;}<br />}<br />
  8. 8. ICostumMapping<br />public partial class Project : ICustomMapping<br />{ <br />[CustomMapping(Columns = new String[] { «Due_x0020_Date», «IsCancelled» })] <br />public void MapFrom(object listItem) <br />{ <br />this.DueDate= ((SPListItem)listItem)[“Due_x0020_Date”]; this.IsCancelled = ((SPListItem)listItem)[“IsCancelled”]; <br />} <br />public void MapTo(object listItem) <br />{ <br />((SPListItem)listItem)[“Due_x0020_Date”] = this.DueDate; ((SPListItem)listItem)[“IsCancelled”] = this.IsCancelled; <br />} <br />public void Resolve(RefreshMode mode, object originalListItem, object databaseObject)<br />{ }<br />}<br />
  9. 9. SPMetal<br />ImtechSPMetalDefinition Extension<br />
  10. 10. LINQ to SharePoint<br />Демо<br />
  11. 11.
  12. 12. Open Data Protocol<br />Открытый доступ к данным<br />Открытыеформаты данных<br />Унифицированная форма запросов<br />
  13. 13. Open Data Protocol<br />Открытый доступ к данным<br />HTTP<br />Открытыеформаты данных<br />AtomPub, JSON<br />Унифицированная форма запросов<br />LINQ<br />
  14. 14. Open Data Protocol<br />Уровень абстракции<br />Широкого доступа<br />Унифицированного доступа<br />Простого доступа<br />
  15. 15. Open Data Protocol<br />Потребители<br />Браузеры<br />OData Explorer<br />Excel 2010 (PowerPivot)<br />LinQPad<br />Visual Studio<br />…<br />
  16. 16. Open Data Protocol<br />http://services.odata.org/OData/OData.svc/<br /><service xml:base="http://services.odata.org/OData/OData.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app"> <br /> <workspace> <br /> <atom:title>Default</atom:title> <br /> <collection href="Products"> <br /> <atom:title>Products</atom:title> <br /> </collection> <br /> <collection href="Categories"> <br /> <atom:title>Categories</atom:title> <br /> </collection> <br /> <collection href="Suppliers"> <br /> <atom:title>Suppliers</atom:title> <br /> </collection> <br /> </workspace> <br /></service><br />
  17. 17. Open Data Protocol<br />http://services.odata.org/OData/OData.svc/Products<br /><?xml version="1.0" encoding="windows-1251" standalone="yes"?><br /><feed xml:base="http://services.odata.org/OData/OData.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"><br /> <title type="text">Products</title><br /> <id>http://services.odata.org/OData/OData.svc/Products</id><br /> <updated>2010-07-01T20:01:57Z</updated><br /> <link rel="self" title="Products" href="Products" /><br /> <entry><br /> <id>http://services.odata.org/OData/OData.svc/Products(0)</id><br /> <title type="text">Bread</title><br /> <summary type="text">Whole grain bread</summary><br /> <updated>2010-07-01T20:01:57Z</updated><br /> <author><br /> <name /><br /> </author>…<br />
  18. 18. Open Data Protocol<br />http://services.odata.org/OData/OData.svc/Products(4)<br /><?xml version="1.0" encoding="windows-1251" standalone="yes"?><br /><entry xml:base="http://services.odata.org/OData/OData.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"><br /> <id>http://services.odata.org/OData/OData.svc/Products(4)</id><br /> <title type="text">Fruit Punch</title><br /> <summary type="text">Mango flavor, 8.3 Ounce Cans (Pack of 24)</summary><br /> <updated>2010-07-01T20:03:37Z</updated><br /> <author><br /> <name /><br /> </author><br /> <link rel="edit" title="Product" href="Products(4)" /><br /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category" type="application/atom+xml;type=entry" title="Category" href="Products(4)/Category" /><br /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(4)/Supplier" /><br /> <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><br /> <content type="application/xml"><br /> <m:properties><br /> <d:ID m:type="Edm.Int32">4</d:ID><br /> <d:ReleaseDate m:type="Edm.DateTime">2003-01-05T00:00:00</d:ReleaseDate><br /> <d:DiscontinuedDate m:type="Edm.DateTime" m:null="true" /><br /> <d:Rating m:type="Edm.Int32">3</d:Rating><br /> <d:Price m:type="Edm.Decimal">22.99</d:Price><br /> </m:properties><br /> </content><br /></entry><br />
  19. 19. Open Data Protocol<br />Типы данных<br />Null<br />Binary<br />Boolean<br />Byte<br />DateTime<br />Decimal<br />Double<br />Single<br />Guid<br />Int16, Int32, Int64<br />Sbyte<br />String<br />Time<br />DateTimeOffset<br />
  20. 20. Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Products<br /><feed xml:base="http://localhost:8080/owind.svc/" ...><br /> ...<br /> <entry><br /> ...<br /> <link rel="edit" title="Product" href="Products(3)" /> <br /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category"<br /> type="application/atom+xml;type=entry" title="Category"<br />href="Products(3)/Category" /> <br /> <link<br />rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details"<br /> type="application/atom+xml;type=feed" title="Order_Details"<br />href="Products(3)/Order_Details" /> <br /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"<br /> type="application/atom+xml;type=entry" title="Supplier"<br />href="Products(3)/Supplier" /> <br /> ...<br /> <content type="application/xml"><br /> <m:properties><br /> <d:ProductID m:type="Edm.Int32">3</d:ProductID> <br /> <d:ProductName>Aniseed Syrup</d:ProductName> <br /> ...<br /> </m:properties><br /> </content><br /> </entry><br /> ...<br /></feed><br />
  21. 21. Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Products<br /><feed xml:base="http://localhost:8080/owind.svc/" ...><br /> ...<br /> <entry><br /> ...<br /> <link rel="edit" title="Product" href="Products(3)" /> <br /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category"<br /> type="application/atom+xml;type=entry" title="Category"<br />href="Products(3)/Category" /> <br /> <link<br />rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details"<br /> type="application/atom+xml;type=feed" title="Order_Details"<br />href="Products(3)/Order_Details" /> <br /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"<br /> type="application/atom+xml;type=entry" title="Supplier"<br />href="Products(3)/Supplier" /> <br /> ...<br /> <content type="application/xml"><br /> <m:properties><br /> <d:ProductID m:type="Edm.Int32">3</d:ProductID> <br /> <d:ProductName>Aniseed Syrup</d:ProductName> <br /> ...<br /> </m:properties><br /> </content><br /> </entry><br /> ...<br /></feed><br />
  22. 22. Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Description<br /><Description xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices"><br />Sweet and savory sauces, relishes, spreads, and seasonings<br /></Description><br />
  23. 23. Open Data Protocol<br />http://localhost:8080/owind.svc/Categories(2)/Description/$value<br />Sweet and savory sauces, relishes, spreads, and seasonings<br />
  24. 24. Open Data Protocol<br />http://localhost:8080/owind.svc/Categories/$count<br />8<br />
  25. 25. Open Data Protocol<br />http://localhost:53211/owind.svc/Categories(4)/$links/Products<br /><links xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices"> <uri>http://localhost:53211/owind.svc/Products(11)</uri> <uri>http://localhost:53211/owind.svc/Products(12)</uri> <uri>http://localhost:53211/owind.svc/Products(31)</uri> <uri>http://localhost:53211/owind.svc/Products(32)</uri> <uri>http://localhost:53211/owind.svc/Products(33)</uri> <uri>http://localhost:53211/owind.svc/Products(59)</uri> <uri>http://localhost:53211/owind.svc/Products(60)</uri> <uri>http://localhost:53211/owind.svc/Products(69)</uri> <uri>http://localhost:53211/owind.svc/Products(71)</uri> <uri>http://localhost:53211/owind.svc/Products(72)</uri> </links><br />
  26. 26. Open Data Protocol<br />http://localhost:8080/owind.svc/Categories?$orderby=CategoryName desc&$top=4<br />http://localhost:53211/owind.svc/Categories?$filter=(CategoryID add 4) eq8<br />http://localhost:53211/owind.svc/Categories?$filter=startswith(CategoryName, 'Sea')<br />
  27. 27. Open Data Protocol<br /><html><br /><head><br /> <title>OData JSON Test</title><br /> <script src="/Scripts/jquery-1.3.2.js" type="text/javascript"></script><br /></head><br /><body><br /> <script type="text/javascript"><br /> $(document).ready(function () {<br /> $("#foo").text("fetching...");<br />varurl = "http://localhost:8080/owind.svc/Categories/";<br /> $.getJSON(url, function (result) {<br /> $("#foo").text(result.d[0].CategoryName);<br /> });<br /> });<br /> </script><br /> <p id="foo">loading page...</p><br /></body><br /></html><br />
  28. 28. Open Data Protocol<br />Объявлять функции<br />Выдавать данные в JSON<br />Наслаждаться жизнью<br />
  29. 29. Open Data Protocol<br />Поставщики<br />SharePoint 2010<br />IBM WebSphere<br />SQL Azure<br />Azure Table Storage<br />SQL Reporting Services<br />…<br />
  30. 30. Open Data Protocol<br />Поставщики<br />Facebook<br />Netflix<br />Pluralsight<br />Stack Overflow<br />Codename Dallas<br />…<br />
  31. 31. Browser, Visual Studio, Python<br />Демо<br />
  32. 32. Готовим OData<br />
  33. 33. Готовим OData<br />Парочка IQueryable<T><br />ADO.NET Data Services v1.5<br />Немного желания<br />
  34. 34. Готовим ODataEntity Framework, LINQ to SQL<br />public class ProductService : DataService<ProductEntities><br />{<br />public static void InitializeService(DataServiceConfigurationconfig)<br />{<br />// Give readonly access to all of the entities<br />config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);<br />// Pagesize will change the max number of rows returned<br />config.SetEntitySetPageSize("*", 25);<br />config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;<br />}<br />}<br />
  35. 35. Готовим ODataReflection Provider<br />public class MyDataSource<br />{ <br /> public IQueryable<Product> Products { get {…} } <br /> public IQueryable<Categories> Categories { get {…} } <br />}<br />public class MyDataSourceService: DataService<MyDataSource><br />{<br />…<br />}<br />
  36. 36. Готовим OData<br />Демо<br />
  37. 37. OData в SharePoint<br />
  38. 38. SharePoint OData<br />Content database<br />SharePoint Data<br />SharePoint<br />LINQ to SharePoint<br />ListData.svc<br />Atom<br />JSON<br />Post, Put, Get<br />Client Application<br />Любая платформа<br /> .NET, Java,<br />Flash, Silverlight<br />
  39. 39. SharePoint OData<br />Операции и HTTP действия<br />Получение данных GET<br />Создание записи POST<br />Изменение записи PUT илиMERGE<br />Удаление записи DELETE<br />И всё это действует на ссылки<br />Все политики SharePoint работают<br />Валидация, Контроль доступа и т.д.<br />
  40. 40. OData в SharePoint<br />Демо<br />
  41. 41. Vitaly Baum<br />http://butaji.ru<br />vbaum@live.com<br />
  42. 42. Ресурсы<br />http://sharepoint.microsoft.com/<br />http://odata.org<br />http://msdn.microsoft.com/en-us/library/ff478141.aspx<br />http://blogs.msdn.com/b/alexj/archive/2010/01/07/data-service-providers-getting-started.aspx<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×