forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 202
Adding entries
object edited this page Feb 12, 2013
·
26 revisions
var product = client
.For("Products")
.InsertEntry(new
{
ProductName = "Test1",
UnitPrice = 18m,
});
Assert.Equal("Test1", product["ProductName"]);
Request URI: POST Products
Request content:
<entry 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">
<title />
<updated>2012-10-08T14:02:51.8990000Z</updated>
<author>
<name />
</author>
<id />
<content type="application/xml">
<m:properties>
<d:ProductName>Test1</d:ProductName>
<d:UnitPrice m:type="Edm.Decimal">18</d:UnitPrice>
</m:properties>
</content>
</entry>
using Entry = System.Collections.Generic.Dictionary<string, object>;
var product = client
.For("Products")
.InsertEntry(new
{
ProductName = "Test1",
UnitPrice = 18m,
});
Assert.True((int)product["ProductID"] > 0);
Request URI: POST Products
Request content:
<entry 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">
<title />
<updated>2012-10-08T14:02:51.8990000Z</updated>
<author>
<name />
</author>
<id />
<content type="application/xml">
<m:properties>
<d:ProductName>Test1</d:ProductName>
<d:UnitPrice m:type="Edm.Decimal">18</d:UnitPrice>
</m:properties>
</content>
</entry>
See also:
Adding entries with links
Modifying data