# IEnumerable va IQuerable

LINQ so\`rovlarda qaytish tipi aniq bo\`lmagan holatlarda ularni to\`plam holatida qabul qilib olish uchun IEnumerable interfeysidan foydalaniladi. Ushbu interfeys System.Collection namespace da joylashgan. IEnumerable C# dasturlash tilidagi barcha to\`plamlar bilan ishlay oladi. Ushbu toifadagi to\`plam elementlariga itteratorlik murojaat mavjud bo\`lgani uchun bemalol foreach takrorlanish operatori yordamida elementlarni olishimiz mumkin bo\`ladi. IEnumerable umumiy tiplar uchun IEnumerable\<T> ko\`rinishda ham murojaat qilish mumkin.

```csharp
static void Main(string[] args)
{
    List<Employee> employees = new List<Employee>()
    {
        new Employee() { id = 1, name = "Jasurbek" },
        new Employee() { id = 2, name = "Muhammadkarim"}
    };
    IEnumerable<Employee> query = from emp in employees
                                  where emp.id == 1
                                  select emp;
    foreach(var item in query)
    {
        Console.WriteLine($"Id = {item.id} Name: {item.name}");
    }
}
class Employee
{
    public int id { get; set; }
    public string name { get; set; }
}
```

IQuerable ham interfeys bo\`lib u System.Linq namespace da joylashgan. IQuerable interfeysi IEnumerable interfeysidan olingan vorisdir. IQuerable Provayderlik hususiyatiga ham ega. Ushbu hususiyat IQueryProvider deb nomlanadi.IQueryProvider LinqProviders dan foydalanadi. IQuerable boshqa provayderlar bilan ishlash jarayonida eng yaxshi ko\`makchi bo\`la oladi (chunki tezlik jihatdan IEnumerable ko\`ra tezroq ishlaydi).

```csharp
static void Main(string[] args)
{
    List<Employee> employees = new List<Employee>()
    {
        new Employee() { id = 1, name = "Jasurbek" },
        new Employee() { id = 2, name = "Muhammadkarim"}
    };

    IQueryable<Employee> query = employees.AsQueryable().Where(x => x.id == 1);

    foreach(var item in query)
    {
        Console.WriteLine($"Id = {item.id} Name: {item.name}");
    }
}
class Employee
{
    public int id { get; set; }
    public string name { get; set; }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dot-net.uz/c-.net/linq/ienumerable-va-iquerable.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
