Junior — Middle
Does ORM Entity Framework support executing queries via LINQ?
sobes.tech AI
Answer from AI
Yes, ORM Entity Framework fully supports executing queries through LINQ (Language Integrated Query). This allows writing database queries in C# using the familiar LINQ syntax, which is then translated into SQL queries executed on the database server.
Example of a LINQ query in Entity Framework:
using(var context = new MyDbContext())
{
var users = context.Users
.Where(u => u.Age > 18)
.OrderBy(u => u.Name)
.ToList();
}
This approach simplifies working with data and ensures type safety of queries.