Scenario: You need to insert a new customer record into a SQL Server database using LINQ to SQL. Which LINQ to SQL method or operation would you use for this task?

  • Add
  • Attach
  • InsertOnSubmit
  • Update
InsertOnSubmit method is used to insert a new record into a LINQ to SQL data context. It queues the object to be inserted upon calling the SubmitChanges method. This method is specifically designed for adding new records. The Add method is not part of LINQ to SQL; it's typically used with Entity Framework. Update is used to modify existing records, and Attach is used to attach existing objects to a data context, not for inserting new records.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *