O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending OData Entity Classes

When adding a service reference to an OData service, the generated entities classes are made partial classes. This provides a useful extensibility point for extending the model, and for providing custom logic within entities themselves.

The EbayModel.Item class, for example, contains a TimeLeft property. This property is provided as a string. If it was of type TimeSpan, however, it would be easier to work with.

This section creates a new partial Item class and, within it, a TimeSpan property that converts the string value provided by the OData service into a TimeSpan value.

The following is an example of the format used by the TimeLeft string:

P0DT0H13M8S

The string contains tokens that indicate value positions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required