New Features in CTP2 ADO.NET Data Services v1.5 Explained
After yesterdays post about the availability of the CTP2 of ADO.NET Data Services v1.5 here are some more details regarding the Projections, Feed Customization and Data Binding.
As told before Projections, the possibility of getting only the columns chosen instead of retrieving all the columns. With this we have now a new set of expressions to provide this ability on the URI, and in order to achieve we have now two new keywords available, that are:
- $select, allow us to define which columns we want to be get
- $expand, defines that along with the results from the requested entity, we also want to get the results from a specific relationship
- But in order for this to work we need to add the following 2 properties to the service:
- For more information’s regarding this subject read this post from the Product Team.
Feed Customizations are the possibility to customize the way the feed is created instead of using only the default AtomPub version.
- In order to achieve this customization we must use the EntityPropertyMappingAttribute that will define the relationship between the Property and the name that will be used in the feed.
In the following sample we are defining that when building the feed, instead of using the complete type definition
1: <author>
2: <name>Nuno Godinho</name>
3: <email>someone@company.com</email>
4: </author>
we will have the Author element with the value that is on the Name Property of the Author class (considering that Author is a type that contains several properties and one of them is Name):
1: [EntityPropertyMapping(
2: "Author",/*Source property path , the property of the Entity type to be mapped*/
3: SyndicationItemProperty.AuthorName,/* Syndication item to which the Source Property is mapped*/
4: SyndicationTextContentKind.Plaintext,/* Syndication content kind for the syndication item this property is bound to */
5: true/* If false the property value is only placed at the mapped location & removed from the <content> section of the atom:entry*/
6: )]
and so the result will be:
1: <author>Nuno Godinho</author>
For more information's regarding this customization read the following posts:
Data Binding is now simplified, because using the DataServiceCollection class we can bind it directly to the Data Service.
- For more information’s regarding this subject read this post from the Product Team.