idictionary,ienumerable ,list efficiently in c#

Posted by Sabarimahesh under C# on 4/10/2012 | Points: 10 | Views : 2898 | Status : [Member] | Replies : 18
what is the difference?

need ur idea with examples.

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M



Responses

Posted by: Sakthi.Singaravel on: 4/10/2012 [Member] Silver | Points: 25

Up
0
Down
see this post..

http://www.dotnetfunda.com/forums/thread8521-how-to-use-idictionaryienumerable-list-etc.aspx

Regards,
Singaravel M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/10/2012 [Member] Silver | Points: 25

Up
0
Down
Diff are,

IQUeryable: As already said by Bruce one should avoid passing Iqueryable to Views.It is not a good place to handle errors...so better getting rid of delayed execution before passing to Views.

IEnumerable. Actually the model binder is not able to bind an enumerable because it is a too generic Interface, and it is not able to choose a concrete class to create that implements the IEnumerable. HOWEVER, you are not forced to use concrete classes, the model binder is able to bind also ICollection<T>, ILIst<T> and IDictionary<T, M>, because each of the above interfaces maps quite naturally in concrete classes...ICollection to array, ILIst to a List and IDictionary to a Dictionary...An IEnumerable is an ancestor of both the above interfaces() also IDictionary<T, M> implements IEnumerable<KeyValuePair<T, M>>) so...it will be difficult for the model binder to choose among them...(in partricular it is not able to verify if the IEnumerable is an IDictionary, or some other complex type defined by the developer)

List<T>: The advantage of using a List is that you can use efficiently indexers in lambda expressions like m => m.MyList[i]. Using lambda expressions with indexers creates the right names for all the field and enables the Model Binder to bind correctly the list when the view is posted, as explained here: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx. Obviously you can create the right names also manually by using the TextBox type helpers instead of the TextBoxFor type...but the last is safer to use since you cannot write a WRONG name (VS 2010 immediately signal the error)

Source: http://forums.asp.net/t/1761294.aspx/1

Regards,
Singaravel M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mani5155 on: 4/10/2012 [Member] Starter | Points: 25

Up
0
Down
i think List<T> is best over other because easy write LINQ. IEnumerable Hard to support it

Top Forums Authors
Mon, 24-Jul-2017 Authors
All Time Authors
Jayakumars
6020
Karthikanbarasan
3455
Oswaldlily
3300

Latest members | More ...


(Statistics delayed by 5 minutes)
Advertisements