InterviewSolution
| 1. |
How Do You Truncate A Table Using Entity Data Model? |
|
Answer» UNFORTUNATELY Entity Framework doesn’t include anything straight forward to HANDLE this. But we can still call a T-SQL statement using entity framework that will still minimizes the developers work. We can call ExecuteStoreCommand() methond on ObjectContext as shown below. CODE: using (var CONTEXT = new MyTestDbEntities()) { context.ExecuteStoreCommand("TRUNCATE table DUMMY"); } Unfortunately Entity Framework doesn’t include anything straight forward to handle this. But we can still call a T-SQL statement using entity framework that will still minimizes the developers work. We can call ExecuteStoreCommand() methond on ObjectContext as shown below. Code: using (var context = new MyTestDbEntities()) { context.ExecuteStoreCommand("TRUNCATE table Dummy"); } |
|