Integration Your Way - (800) 235-7250
RSSBus ADO.NET Provider for SalesForce V2
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.SalesForce;

//...

Entities context = new Entities();

Account newRecord = new Account {
  Name = "Floppy Disks"
};

context.Accounts.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. Here is the code necessary to retrieve the Id of a newly inserted record:

var conn = (context.Connection as EntityConnection).StoreConnection as SalesForceConnection;
Hashtable result = conn.GetLastResult();
String Id = result["id"];


 
Copyright © 2013 RSSBus Inc.
[x] close

Questions / Feedback?


Name:
Email:
Feedback:
Send Feedback