Câu hỏi phỏng vấn C#
Câu hỏi

What are the differences betwe...

Câu trả lời

Here are the key differences between IEnumerable and IQueryable in C#:

Execution of Queries

  • IEnumerable: Queries are executed on the client-side, meaning the entire data set is retrieved from the data source and processed in memory.
  • IQueryable: Queries are executed on the server-side, allowing the data source to handle the query processing and return only the necessary data.

Deferred Execution

  • IEnumerable: Queries are executed when the result is accessed (e.g., when iterating over the collection using a foreach loop).
  • IQueryable: Queries are executed when the result is accessed, but the query is translated into a data source-specific query language (e.g., SQL for a database).

Filtering and Projection

  • IEnumerable: Filtering and projection operations are performed on the client-side using LINQ methods like Where(), Select(), etc.
  • IQueryable: Filtering and projection operations are translated into data source-specific query language and executed on the server-side.

Lazy Loading

  • IEnumerable: Data is loaded eagerly, meaning the entire data set is retrieved fro...
expert

expert

Gợi ý câu hỏi phỏng vấn

senior

What are the different ways a method can be overloaded?

senior

What is Marshalling and why do we need it?

junior

What is Managed or Unmanaged Code?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào