أسئلة القسم
تدرب على أسئلة المقابلات في هذا القسم. اكتب إجابتك، قم بتقييمها، أو اضغط على "عرض الإجابة" بعد التفكير.
What is LINQ in .NET, and how does Fluent API relate? سهل
LINQ (Language Integrated Query) → A set of features that brings query capabilities into C#.
Fluent API → A style of writing LINQ queries using method chaining (.Where().Select()) instead of SQL-like syntax.
Both achieve the same goal; Fluent API is essentially method syntax.
What are the advantages of using LINQ over traditional SQL queries or loops? سهل
- Strongly typed, compile-time checking.
- IntelliSense support in Visual Studio.
- Readable and maintainable code.
- Consistent querying across objects, XML, SQL, EF, etc.
What are Anonymous Types in LINQ, and when would you use them? سهل
Allow you to project results into objects without defining a class.
var result = from e in employees
select new { e.Name, e.Salary };
Useful for temporary data shapes in queries.
What is the difference between Method Syntax and Query Syntax in LINQ? Which one is better? سهل
Query syntax → SQL-like (from e in employees where e.Age > 30 select e;).
Method syntax → Fluent chaining (employees.Where(e => e.Age > 30)).
Both compile to the same IL. Method syntax is more powerful (supports Join, GroupBy, etc.).