Friday, April 19, 2013

Data Collection Objects

- IEnumerable : a list object that can be only iterated through. It supports generic type and enforces type-safety.
- ICollection: a list object that can be iterated through and modified. It supports generic type and enforces type-safety.
- List: a list object that can be iterated through, modified, and sorted. It supports generic type and enforces type-safety.
- IQueryable : is for an interface LINQ-to-SQL

e.g. IEnuerable <Persons> persons=  PersonModel.GetPerson();
          var  person_female= persons.Where (p=>p.gender=="F");

The database will load all the person from the database. Then filter is applied in the program. So, all the records are loaded from the database, and the filter is applied.

e.g. IQueryable<Persons> persons=  PersonModel.GetPerson();
      var  person_female= persons.Where (p=>p.gender=="F"); // the data is retrieved here

The database's execution is : "Select * from Persons where Gender="F"). So, only the records with Gender="F" are returned to the program.

- HashTable: non-generic, it doesn't enforce type-safety
- Dictionary:  a hashtable that supports generic type and enforces type-safety
- Array
- ArrayList : doesn't support generic type, so it doesn't enforces type-satety
- Stack: LIFO
- Queue: FIFO

No comments:

Post a Comment