Example:
In ODataService sample, Product entity type has a required relationship with ProductFamily. Product cannot exist without a Product Family.
Currently we can submit a Product without any existing relationship with a ProductFamily. I believe we should throw some kind of validation error. According to 'deep insert' we could supply the rel links to which you would want to associate the to-be-created entity instance. Since this scenario is fairly common, we should support it.
Following is an example from the OData PDF spec:
2.2.7.1.1.1 Examples
---------------------
Example 1: Insert a new Customer and bind it to existing Orders with key values 1 and 2 by using the Atom format.
HTTP Request:
-------------
POST /service.svc/Customers HTTP/1.1
Host: host
Content-Type: application/atom+xml
Accept: application/atom+xml
Content-Length: nnn
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://host/service.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://host/service.svc/Customers('ASDFG')</id>
<title type="text" />
<updated>2008-12-07T8:00:00Z</updated>
<author>
<name />
</author>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" href="Orders(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" href="Orders(2)" />
<content type="application/xml">
<m:properties>
<d:CustomerID>ASDFG</d:CustomerID>
<d:CompanyName>Contoso Widgets</d:CompanyName>
<d:Address>
<d:Street>58 Contoso St</d:Street>
<d:City>Seattle</d:City>
</d:Address>
</m:properties>
</content>
</entry>
Comments: I do not agree that this is a rare case. This kind of scenario is common in relational data. Example: We cannot create an Order without associating it with an existing Customer. So validating here for atleast presence of the relational links in the incoming Order is a natural thing to do.
In ODataService sample, Product entity type has a required relationship with ProductFamily. Product cannot exist without a Product Family.
Currently we can submit a Product without any existing relationship with a ProductFamily. I believe we should throw some kind of validation error. According to 'deep insert' we could supply the rel links to which you would want to associate the to-be-created entity instance. Since this scenario is fairly common, we should support it.
Following is an example from the OData PDF spec:
2.2.7.1.1.1 Examples
---------------------
Example 1: Insert a new Customer and bind it to existing Orders with key values 1 and 2 by using the Atom format.
HTTP Request:
-------------
POST /service.svc/Customers HTTP/1.1
Host: host
Content-Type: application/atom+xml
Accept: application/atom+xml
Content-Length: nnn
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://host/service.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://host/service.svc/Customers('ASDFG')</id>
<title type="text" />
<updated>2008-12-07T8:00:00Z</updated>
<author>
<name />
</author>
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" href="Orders(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" href="Orders(2)" />
<content type="application/xml">
<m:properties>
<d:CustomerID>ASDFG</d:CustomerID>
<d:CompanyName>Contoso Widgets</d:CompanyName>
<d:Address>
<d:Street>58 Contoso St</d:Street>
<d:City>Seattle</d:City>
</d:Address>
</m:properties>
</content>
</entry>
Comments: I do not agree that this is a rare case. This kind of scenario is common in relational data. Example: We cannot create an Order without associating it with an existing Customer. So validating here for atleast presence of the relational links in the incoming Order is a natural thing to do.