أسئلة القسم
تدرب على أسئلة المقابلات في هذا القسم. اكتب إجابتك، قم بتقييمها، أو اضغط على "عرض الإجابة" بعد التفكير.
Explain the concept of Expression Trees in LINQ. صعب
An expression tree represents code as a data structure (an object graph).
LINQ providers like EF Core use them to translate C# expressions into SQL.
They live in System.Linq.Expressions.
What happens when you write LINQ queries on in-memory collections vs databases? صعب
In-memory (LINQ to Objects):
Operates directly on IEnumerable
Uses C# delegates and executes in the CLR.
Example: List
Database (LINQ to Entities/SQL):
Operates on IQueryable
Translates the expression tree into SQL.
Query executed on DB server, results materialized into objects
Example:
// In-memory
var local = list.Where(x => x > 10); // runs in CLR
// EF Core -> SQL
var dbQuery = db.Users.Where(x => x.Age > 18); // translated to SELECT ... WHERE Age > 18
Key difference: Execution location (memory vs DB).