Junior — Middle
What result does the ORM return after performing a database operation?
sobes.tech AI
Answer from AI
After performing a database operation, ORM usually returns:
- For SELECT operations — a collection or an object with data corresponding to the query.
- For INSERT operations — an object with the updated state, for example, with an automatically generated identifier.
- For UPDATE and DELETE operations — the number of affected records (e.g., the number of changed rows).
Example in C# with Entity Framework:
var user = new User { Name = "John" };
dbContext.Users.Add(user);
dbContext.SaveChanges();
// user.Id now contains the generated key
Thus, ORM returns either data or information about the operation result, which simplifies working with the database.