Integration Your Way - (800) 235-7250
RSSBus ADO.NET Provider for Amazon SimpleDB
Questions / Feedback? LINQ Inserts

LINQ Inserts

The following example illustrates inserting a record using LINQ.

using System.Linq;
using System.Data.EntityClient;
using System.Data.RSSBus.SimpleDB;

//...

Entities context = new Entities();

Lead newRecord = new Lead {
  FullName = "The Joker"
};

context.Leads.AddObject(newRecord);

try {
  context.SaveChanges();
} catch (Exception e) {
  Console.WriteLine(e);
}

It is often useful to retrieve the result of the insert command to, say, obtain the new record's Id. You can do so by reading the Id from the record after it has been saved. The database generated Id will be assigned to the saved record.

newRecord.Id


 
Copyright © 2013 RSSBus Inc.
[x] close

Questions / Feedback?


Name:
Email:
Feedback:
Send Feedback