Back to Search Start Over

How to use IEnumerable, ICollection, IList, and IQueryable in C#

Authors :
1, Authors = New List<Author>(){ New Author(){Id =
"Joydip", FirstName =
"Kanjilal", LastName =
True}, IsActive =
2, New Author(){Id =
"Michael", FirstName =
"Smith", LastName =
False}, IsActive =
3, New Author(){Id =
"Steve", FirstName =
"Jones", LastName =
Datasets, IsActive = True}};IQueryable<Author> Query = Authors.AsQueryable() .Where(A => A.IsActive == True);Foreach (Var Author In Query){ Console.WriteLine($"Id : {Author.Id} FirstName : {Author.FirstName} LastName : {Author.LastName}");}<P>The IQueryable Interface Is Appropriate For Working With Large
IEnumerable, Particularly When You Need To Implement Paging To Retrieve Only The Data You Need.</P><H2>Which Collection Interface Should You Use?</H2><P>Here'S A Quick Recap Of The Features Of The
ICollection
IList
Read-Only, And IQueryable Interfaces.</P><Li>IEnumerable Allows You To Access Elements Of A Collection In A.
Adding, Forward-Only Manner. No
Deleting
Adding, Or Modifying The Elements.</Li><Li>ICollection Inherits From The IEnumerable Interface And Provides Additional Functionality Including
Adding, And Modifying Elements.</Li><Li>IList Extends The ICollection Interface And Represents Strongly Typed Collections That Are Accessible Via Index. So In Addition To
Modifying, And
Interface, You Can Insert Or Remove Items Using Index Values.</Li><Li>IQueryable Extends The IEnumerable
Linq, Provides Support For
Entities, And Is Well-Suited For Working With Large Datasets. When You Use Iqueryable With Linq To Sql Or Linq To
Database, It Generates A Linq To Sql Expression That Is Executed In The Data Layer Of Your Application.</Li><P>The Choice Of Collection Interface In C# Will Depend On The Requirements Of Your Application. If You Want To Query Data From A.
Memory, Use IQueryable. If You Want To Query Data From
IEnumerable, Then Use
IList, Or
<pubDate>Thu, Depending On What You Want To Do With The Elements Of The Collection. </P>]]></Description>
Kanjilal, 21 Dec 2023 02:00:00 -0800</Pubdate> <Author> Joydip
Source :
InfoWorld.com. December 21, 2023
Publication Year :
2023

Abstract

Byline: authors = new List(){ new Author(){Id = 1, FirstName = &#39;Joydip&#39;, LastName = &#39;Kanjilal&#39;, IsActive = true}, new Author(){Id = 2, FirstName = &#39;Michael&#39;, LastName = &#39;Smith&#39;, IsActive = [...]

Details

Language :
English
Database :
Gale General OneFile
Journal :
InfoWorld.com
Publication Type :
Periodical
Accession number :
edsgcl.776895672