The One With

June 2010 - Posts

  • OData Provider for XPO – Complex Types

    Now that we know how to expose XPO objects as OData feeds and how to consume them, let’s cover some implementation details that you will need to know when facing real world scenarios.

    Complex Types

    In XPO, there are no constructs that separate entity types from complex types. You define your objects, you create your relationships between them and that’s it, you use them. Whether or not your one-to-one relationship is Complex or Reference is really irrelevant. We don’t store object data in blob fields so the concept of complex types only comes to play at the presentation layer. And if you think about it, serialized data could be classified as one. For this purpose, there is a new attribute DevExpress.Xpo.Services.ComplexAttribute that you can mark an XPO object with.

    For example the DevExpress Channel Feed publishes video statistics as a complex object.

     
    <feed xml:base="http://media.devexpress.com/Channel.svc/">
      <entry>
        <id>../Video(guid'367f159c-1686-425d-9b95-bf23bb705ab9')</id>
        <category term="DevExpress.Channel.DataModel.Video"/>
        <content type="application/xml">
          <m:properties>
            <d:Oid m:type="Edm.Guid">367f159c-1686-425d-9b95-bf23bb705ab9</d:Oid>
            <d:Title>Reporting Tool - Creating a Data-Aware Report</d:Title>
            <d:Date m:type="Edm.DateTime">2008-10-20T00:00:00</d:Date>
            <d:Statistics m:type="DevExpress.Channel.DataModel.Statistics">
              <d:Oid m:type="Edm.Guid">aff87c23-3bc4-4771-83b9-25b4c7b34876</d:Oid>
              <d:Count m:type="Edm.Int32">10087</d:Count>
              <d:CompletedCount m:type="Edm.Int32">2843</d:CompletedCount>
            </d:Statistics>
          </m:properties>
        </content>
      </entry>
    </feed>
    
    [Complex]
    public class Statistics : XPLiteObject {
        public Guid Oid;
        public int Count;
        public int CompletedCount;
    }
    public class Video : XPLiteObject {
        public Statistics Statistics;
        public Guid Oid;
        public string Title;
        public DateTime Date;
    }

    If we remove the Complex attribute from Statistics our feed will change to:

    <feed xml:base="http://media.devexpress.com/Channel.svc/">
      <entry>
        <id>../Video(guid'367f159c-1686-425d-9b95-bf23bb705ab9')</id>
        <link title="Statistics" href="Video(guid'367f159c-1686-425d-9b95-bf23bb705ab9')/Statistics" />
        <category term="DevExpress.Channel.DataModel.Video"/>
        <content type="application/xml">
          <m:properties>
            <d:Oid m:type="Edm.Guid">367f159c-1686-425d-9b95-bf23bb705ab9</d:Oid>
            <d:Title>Reporting Tool - Creating a Data-Aware Report</d:Title>
            <d:Date m:type="Edm.DateTime">2008-10-20T00:00:00</d:Date>
          </m:properties>
        </content>
      </entry>
    </feed>
    

    Note: It’s important to know that a ResourceSet will not be created for complex objects.

    Cheers

    Azret

LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2017 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners