O'Reilly logo

Entity Framework Tutorial - Second Edition by Joydip Kanjilal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Other operations with E-SQL

In this section, we will take a look at how we can perform some additional operations with the E-SQL language. We will discuss the following:

  • Inserting a record using E-SQL
  • Inserting a record with a foreign key constraint
  • Retrieving native SQL from EntityCommand
  • Transaction management in E-SQL

Inserting a record using E-SQL

You can use E-SQL statements and easily perform CRUD operations. Let's assume that you have a stored procedure called InsertDesignation and you would like to use it to store a record in the designation table of your Payroll database. This is the code:

using (EntityConnection var conn = new EntityConnection("Name=PayrollEntities")) { try { conn.Open(); EntityCommandvar cmd = conn.CreateCommand(); cmd.CommandText ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required