Client Interfaces Guide > TIBCO ADO.NET 2020 Data Provider for TDV > Using ADO.NET (LINQ) > LINQ Inserts
 
LINQ Inserts
This section provides an example of how to obtain and insert TDV objects with LINQ.
 
Inserting TDV Objects with LINQ to Entities
The following code adds a new Products object:
 
using System.Linq;
CompositeEntities context = new CompositeEntities();
Products newRecord = new Products {
ProductName = "Konbu"
};
context.Products.Add(newRecord);
try {
context.SaveChanges();
Console.WriteLine(newRecord.Id);
} catch (Exception e) {
Console.WriteLine(e);
}
Note: It is often useful to retrieve the result of the insert command. For example, when obtaining the Id of the new record. You can do so by reading the Id from the record after it has been saved. The primary key, generated by the data source, is assigned to the saved record.