Multiple results

LINQ always operates on collections and by default, a collection is also a result. If the collection is of IQuearyble<object> type, you can convert it to a generic list by using the ToList() method:

List<Customer> customers =
    context.Customers
        .ToList();

If you use a Where method, for example, you limit the selection but the result is yet again a collection of objects that you can convert to a list:

List<Customer> customers =
    context.Customers
        .Where(c => c.Country == "USA")
            .ToList();

Should you have any questions or found a mistake that needs correcting, feel free to send an email to: info [at] linqtutorial [dot] info


Advertisements :