Your SlideShare is downloading. ×
SharePoint, LINQ, OData
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

SharePoint, LINQ, OData

1,542
views

Published on

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

Презентация с семинара "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,542
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. SharePoint, LINQ иOpen Data Protocol
    Vitaly Baum
    Senior SharePoint Developer @ Conteq
    Активный участник групп разработчиков в Санкт-Петербурге и Москве, подкастер и блоггер
    http://butaji.ru
  • 2. План выступления
    LINQ to SharePoint 2010
    Open Data Protocol
  • 3. LINQ to SharePoint
  • 4. Преимущества LINQ
    Строгая типизация
    Запросы к реляционным данным в строго-типизированной форме
    Компилятор проверит ошибки в запросах
    IntelliSense
    Унифицированный путь получения данных из любого источника
  • 5. LINQ to SharePoint
    SPMetal
    Генерирует DataContext
    SPMetal /web:http://ContosoServer/Marketing /code:MarketingSite.cs 
  • 6. LINQ to SharePoint
    Недостатки
    Преобразуется в CAML
    Не все операторы реализованы
    Двухэтапные запросы
    Аггрегирующие запросы
    SPSiteDataQuery
  • 7. Mapping
    internal partial class OrganisationSiteDataContext : Microsoft.SharePoint.Linq.DataContext{}
    [ContentType(Name = "Employee")]
    public partial class Employee
    {
    [Column(Name="ID", IsId=true, ReadOnly=true, FieldType="Counter")]
    public int Id {get; set;}
    }
  • 8. ICostumMapping
    public partial class Project : ICustomMapping
    {
    [CustomMapping(Columns = new String[] { «Due_x0020_Date», «IsCancelled» })]
    public void MapFrom(object listItem)
    {
    this.DueDate= ((SPListItem)listItem)[“Due_x0020_Date”]; this.IsCancelled = ((SPListItem)listItem)[“IsCancelled”];
    }
    public void MapTo(object listItem)
    {
    ((SPListItem)listItem)[“Due_x0020_Date”] = this.DueDate; ((SPListItem)listItem)[“IsCancelled”] = this.IsCancelled;
    }
    public void Resolve(RefreshMode mode, object originalListItem, object databaseObject)
    { }
    }
  • 9. SPMetal
    ImtechSPMetalDefinition Extension
  • 10. LINQ to SharePoint
    Демо
  • 11.
  • 12. Open Data Protocol
    Открытый доступ к данным
    Открытыеформаты данных
    Унифицированная форма запросов
  • 13. Open Data Protocol
    Открытый доступ к данным
    HTTP
    Открытыеформаты данных
    AtomPub, JSON
    Унифицированная форма запросов
    LINQ
  • 14. Open Data Protocol
    Уровень абстракции
    Широкого доступа
    Унифицированного доступа
    Простого доступа
  • 15. Open Data Protocol
    Потребители
    Браузеры
    OData Explorer
    Excel 2010 (PowerPivot)
    LinQPad
    Visual Studio

  • 16. Open Data Protocol
    http://services.odata.org/OData/OData.svc/
    <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">
    <workspace>
    <atom:title>Default</atom:title>
    <collection href="Products">
    <atom:title>Products</atom:title>
    </collection>
    <collection href="Categories">
    <atom:title>Categories</atom:title>
    </collection>
    <collection href="Suppliers">
    <atom:title>Suppliers</atom:title>
    </collection>
    </workspace>
    </service>
  • 17. Open Data Protocol
    http://services.odata.org/OData/OData.svc/Products
    <?xml version="1.0" encoding="windows-1251" standalone="yes"?>
    <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">
    <title type="text">Products</title>
    <id>http://services.odata.org/OData/OData.svc/Products</id>
    <updated>2010-07-01T20:01:57Z</updated>
    <link rel="self" title="Products" href="Products" />
    <entry>
    <id>http://services.odata.org/OData/OData.svc/Products(0)</id>
    <title type="text">Bread</title>
    <summary type="text">Whole grain bread</summary>
    <updated>2010-07-01T20:01:57Z</updated>
    <author>
    <name />
    </author>…
  • 18. Open Data Protocol
    http://services.odata.org/OData/OData.svc/Products(4)
    <?xml version="1.0" encoding="windows-1251" standalone="yes"?>
    <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">
    <id>http://services.odata.org/OData/OData.svc/Products(4)</id>
    <title type="text">Fruit Punch</title>
    <summary type="text">Mango flavor, 8.3 Ounce Cans (Pack of 24)</summary>
    <updated>2010-07-01T20:03:37Z</updated>
    <author>
    <name />
    </author>
    <link rel="edit" title="Product" href="Products(4)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category" type="application/atom+xml;type=entry" title="Category" href="Products(4)/Category" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(4)/Supplier" />
    <category term="ODataDemo.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
    <m:properties>
    <d:ID m:type="Edm.Int32">4</d:ID>
    <d:ReleaseDate m:type="Edm.DateTime">2003-01-05T00:00:00</d:ReleaseDate>
    <d:DiscontinuedDate m:type="Edm.DateTime" m:null="true" />
    <d:Rating m:type="Edm.Int32">3</d:Rating>
    <d:Price m:type="Edm.Decimal">22.99</d:Price>
    </m:properties>
    </content>
    </entry>
  • 19. Open Data Protocol
    Типы данных
    Null
    Binary
    Boolean
    Byte
    DateTime
    Decimal
    Double
    Single
    Guid
    Int16, Int32, Int64
    Sbyte
    String
    Time
    DateTimeOffset
  • 20. Open Data Protocol
    http://localhost:8080/owind.svc/Categories(2)/Products
    <feed xml:base="http://localhost:8080/owind.svc/" ...>
    ...
    <entry>
    ...
    <link rel="edit" title="Product" href="Products(3)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category"
    type="application/atom+xml;type=entry" title="Category"
    href="Products(3)/Category" />
    <link
    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details"
    type="application/atom+xml;type=feed" title="Order_Details"
    href="Products(3)/Order_Details" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
    type="application/atom+xml;type=entry" title="Supplier"
    href="Products(3)/Supplier" />
    ...
    <content type="application/xml">
    <m:properties>
    <d:ProductID m:type="Edm.Int32">3</d:ProductID>
    <d:ProductName>Aniseed Syrup</d:ProductName>
    ...
    </m:properties>
    </content>
    </entry>
    ...
    </feed>
  • 21. Open Data Protocol
    http://localhost:8080/owind.svc/Categories(2)/Products
    <feed xml:base="http://localhost:8080/owind.svc/" ...>
    ...
    <entry>
    ...
    <link rel="edit" title="Product" href="Products(3)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Category"
    type="application/atom+xml;type=entry" title="Category"
    href="Products(3)/Category" />
    <link
    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Order_Details"
    type="application/atom+xml;type=feed" title="Order_Details"
    href="Products(3)/Order_Details" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Supplier"
    type="application/atom+xml;type=entry" title="Supplier"
    href="Products(3)/Supplier" />
    ...
    <content type="application/xml">
    <m:properties>
    <d:ProductID m:type="Edm.Int32">3</d:ProductID>
    <d:ProductName>Aniseed Syrup</d:ProductName>
    ...
    </m:properties>
    </content>
    </entry>
    ...
    </feed>
  • 22. Open Data Protocol
    http://localhost:8080/owind.svc/Categories(2)/Description
    <Description xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
    Sweet and savory sauces, relishes, spreads, and seasonings
    </Description>
  • 23. Open Data Protocol
    http://localhost:8080/owind.svc/Categories(2)/Description/$value
    Sweet and savory sauces, relishes, spreads, and seasonings
  • 24. Open Data Protocol
    http://localhost:8080/owind.svc/Categories/$count
    8
  • 25. Open Data Protocol
    http://localhost:53211/owind.svc/Categories(4)/$links/Products
    <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>
  • 26. Open Data Protocol
    http://localhost:8080/owind.svc/Categories?$orderby=CategoryName desc&$top=4
    http://localhost:53211/owind.svc/Categories?$filter=(CategoryID add 4) eq8
    http://localhost:53211/owind.svc/Categories?$filter=startswith(CategoryName, 'Sea')
  • 27. Open Data Protocol
    <html>
    <head>
    <title>OData JSON Test</title>
    <script src="/Scripts/jquery-1.3.2.js" type="text/javascript"></script>
    </head>
    <body>
    <script type="text/javascript">
    $(document).ready(function () {
    $("#foo").text("fetching...");
    varurl = "http://localhost:8080/owind.svc/Categories/";
    $.getJSON(url, function (result) {
    $("#foo").text(result.d[0].CategoryName);
    });
    });
    </script>
    <p id="foo">loading page...</p>
    </body>
    </html>
  • 28. Open Data Protocol
    Объявлять функции
    Выдавать данные в JSON
    Наслаждаться жизнью
  • 29. Open Data Protocol
    Поставщики
    SharePoint 2010
    IBM WebSphere
    SQL Azure
    Azure Table Storage
    SQL Reporting Services

  • 30. Open Data Protocol
    Поставщики
    Facebook
    Netflix
    Pluralsight
    Stack Overflow
    Codename Dallas

  • 31. Browser, Visual Studio, Python
    Демо
  • 32. Готовим OData
  • 33. Готовим OData
    Парочка IQueryable<T>
    ADO.NET Data Services v1.5
    Немного желания
  • 34. Готовим ODataEntity Framework, LINQ to SQL
    public class ProductService : DataService<ProductEntities>
    {
    public static void InitializeService(DataServiceConfigurationconfig)
    {
    // Give readonly access to all of the entities
    config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
    // Pagesize will change the max number of rows returned
    config.SetEntitySetPageSize("*", 25);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }
    }
  • 35. Готовим ODataReflection Provider
    public class MyDataSource
    {
    public IQueryable<Product> Products { get {…} }
    public IQueryable<Categories> Categories { get {…} }
    }
    public class MyDataSourceService: DataService<MyDataSource>
    {

    }
  • 36. Готовим OData
    Демо
  • 37. OData в SharePoint
  • 38. SharePoint OData
    Content database
    SharePoint Data
    SharePoint
    LINQ to SharePoint
    ListData.svc
    Atom
    JSON
    Post, Put, Get
    Client Application
    Любая платформа
    .NET, Java,
    Flash, Silverlight
  • 39. SharePoint OData
    Операции и HTTP действия
    Получение данных GET
    Создание записи POST
    Изменение записи PUT илиMERGE
    Удаление записи DELETE
    И всё это действует на ссылки
    Все политики SharePoint работают
    Валидация, Контроль доступа и т.д.
  • 40. OData в SharePoint
    Демо
  • 41. Vitaly Baum
    http://butaji.ru
    vbaum@live.com
  • 42. Ресурсы
    http://sharepoint.microsoft.com/
    http://odata.org
    http://msdn.microsoft.com/en-us/library/ff478141.aspx
    http://blogs.msdn.com/b/alexj/archive/2010/01/07/data-service-providers-getting-started.aspx