Blogs

The One With

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

Published Jun 10 2010, 01:56 AM by Azret Botash (DevExpress)
Filed under: , ,
Technorati tags: XPO, OData, WCF Data Services
Bookmark and Share

Comments

No Comments
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.