Skip to content
object edited this page Oct 8, 2012 · 26 revisions

Simple.Data method Insert is used to create new entries in OData collections.

Insert an entry by specifying all it's fields:
Request URI: 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>
var product = _db.Products.Insert(ProductName: "Test1", UnitPrice: 18m);
Assert.Equal("Test1", product.ProductName);

See also:
Modifying data
Simple.Data documentation for Insert

Clone this wiki locally