SharePoint, LINQ, OData
Upcoming SlideShare
Loading in...5
×
 

SharePoint, LINQ, OData

on

  • 1,940 views

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

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

Statistics

Views

Total Views
1,940
Views on SlideShare
1,940
Embed Views
0

Actions

Likes
0
Downloads
10
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    SharePoint, LINQ, OData SharePoint, LINQ, OData Presentation Transcript

    • SharePoint, LINQ иOpen Data Protocol
      Vitaly Baum
      Senior SharePoint Developer @ Conteq
      Активный участник групп разработчиков в Санкт-Петербурге и Москве, подкастер и блоггер
      http://butaji.ru
    • План выступления
      LINQ to SharePoint 2010
      Open Data Protocol
    • LINQ to SharePoint
    • Преимущества LINQ
      Строгая типизация
      Запросы к реляционным данным в строго-типизированной форме
      Компилятор проверит ошибки в запросах
      IntelliSense
      Унифицированный путь получения данных из любого источника
    • LINQ to SharePoint
      SPMetal
      Генерирует DataContext
      SPMetal /web:http://ContosoServer/Marketing /code:MarketingSite.cs 
    • LINQ to SharePoint
      Недостатки
      Преобразуется в CAML
      Не все операторы реализованы
      Двухэтапные запросы
      Аггрегирующие запросы
      SPSiteDataQuery
    • 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;}
      }
    • 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)
      { }
      }
    • SPMetal
      ImtechSPMetalDefinition Extension
    • LINQ to SharePoint
      Демо
    • Open Data Protocol
      Открытый доступ к данным
      Открытыеформаты данных
      Унифицированная форма запросов
    • Open Data Protocol
      Открытый доступ к данным
      HTTP
      Открытыеформаты данных
      AtomPub, JSON
      Унифицированная форма запросов
      LINQ
    • Open Data Protocol
      Уровень абстракции
      Широкого доступа
      Унифицированного доступа
      Простого доступа
    • Open Data Protocol
      Потребители
      Браузеры
      OData Explorer
      Excel 2010 (PowerPivot)
      LinQPad
      Visual Studio

    • 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>
    • 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>…
    • 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>
    • Open Data Protocol
      Типы данных
      Null
      Binary
      Boolean
      Byte
      DateTime
      Decimal
      Double
      Single
      Guid
      Int16, Int32, Int64
      Sbyte
      String
      Time
      DateTimeOffset
    • 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>
    • 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>
    • 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>
    • Open Data Protocol
      http://localhost:8080/owind.svc/Categories(2)/Description/$value
      Sweet and savory sauces, relishes, spreads, and seasonings
    • Open Data Protocol
      http://localhost:8080/owind.svc/Categories/$count
      8
    • 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>
    • 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')
    • 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>
    • Open Data Protocol
      Объявлять функции
      Выдавать данные в JSON
      Наслаждаться жизнью
    • Open Data Protocol
      Поставщики
      SharePoint 2010
      IBM WebSphere
      SQL Azure
      Azure Table Storage
      SQL Reporting Services

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

    • Browser, Visual Studio, Python
      Демо
    • Готовим OData
    • Готовим OData
      Парочка IQueryable<T>
      ADO.NET Data Services v1.5
      Немного желания
    • Готовим 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;
      }
      }
    • Готовим ODataReflection Provider
      public class MyDataSource
      {
      public IQueryable<Product> Products { get {…} }
      public IQueryable<Categories> Categories { get {…} }
      }
      public class MyDataSourceService: DataService<MyDataSource>
      {

      }
    • Готовим OData
      Демо
    • OData в SharePoint
    • SharePoint OData
      Content database
      SharePoint Data
      SharePoint
      LINQ to SharePoint
      ListData.svc
      Atom
      JSON
      Post, Put, Get
      Client Application
      Любая платформа
      .NET, Java,
      Flash, Silverlight
    • SharePoint OData
      Операции и HTTP действия
      Получение данных GET
      Создание записи POST
      Изменение записи PUT илиMERGE
      Удаление записи DELETE
      И всё это действует на ссылки
      Все политики SharePoint работают
      Валидация, Контроль доступа и т.д.
    • OData в SharePoint
      Демо
    • Vitaly Baum
      http://butaji.ru
      vbaum@live.com
    • Ресурсы
      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