Questions tagged [icollection]

The ICollection interface is the base interface for classes in the System.Collections namespace. It defines size, enumerators, and synchronization methods for all non-generic collections

The ICollection interface is the base interface for classes in the System.Collections namespace.

The ICollection interface extends IEnumerable; IDictionary and IList are more specialized interfaces that extend ICollection. An IDictionary implementation is a collection of key/value pairs, like the Hashtable class. An IList implementation is a collection of values and its members can be accessed by index, like the ArrayList class.

Some collections that limit access to their elements, such as the Queue class and the Stack class, directly implement the ICollection interface.

If neither the IDictionary interface nor the IList interface meet the requirements of the required collection, derive the new collection class from the ICollection interface instead for more flexibility.

279 questions
0
votes
3 answers

How to add the IEnumerable collection to ICollection list?

I add the method for adding Ienumerable collection to Icollection. public static ICollection AddTo(this IEnumerable list,ICollection collection) { foreach (T item in list) { collection.Add(item); } return…
user3106578
  • 177
  • 1
  • 2
  • 12
0
votes
1 answer

C#: ICollection with Interface as Type like ICollection

Im working with EntitFramework which generates my Entity classes: I have these classes: public class Car { //... public String Brand { get; set; } //... public virtual ICollection CarLocalizeds { get; set; } …
user2838883
0
votes
2 answers

Lambda loop thru ICollection failed to find object property

I have a list of objects as ICollection listA. Now I'm trying to loop thru this listA and trying to match a condition and assign the result found into a variable. I tried below: varB.someDesc = listA.FirstOrDefault(x=>x.ID ==…
SuicideSheep
  • 5,260
  • 19
  • 64
  • 117
0
votes
1 answer

Linq Remove an uncommitted entity from an Entity Collection - How do you find the right one?

My RadGrid is populated from an entity framework ICollection held in Session State. The primary key is an auto incremented field in the database. A user can add multiple rows to the grid without submitting them to the database. If the user…
Stoertz
  • 7
  • 6
0
votes
2 answers

implement IEnumerator and IEnumerable in ICollection

I am very new to this ICollection stuff and need some guidance of how to implement the IEnumerable and IEnumerator. I have checked Microsoft documentation and I think I understand what was said there (I think). But when I tried to implement it in my…
user1205746
  • 3,110
  • 11
  • 44
  • 73
0
votes
1 answer

Way to check if any object in ICollection have the same ID value

I have an Object that is a ICollection type() . I want to check in this object if there are same ID values. If there's same ID i want that a property of two different item are merged. how i can make it?
0
votes
1 answer

How to bind ICollection property to MVC4 View?

I have defined a model as below- public class Question { public int Id { get; set; } public string Title { get; set; } public int UserSelection { get; set; } public Question() { this.Options = new List
Abhijeet
  • 13,562
  • 26
  • 94
  • 175
0
votes
1 answer

How to show ICollection count in jQuery tmpl?

In my POCO model, I have a collection property defined as public virtual ICollection Positions { get; set; } Now, in my jquery tmpl, I'd like to show the count of Positions property in a jquery tmpl like
newman
  • 6,841
  • 21
  • 79
  • 126
0
votes
1 answer

Generic collection in .net that allow birectional iteration

I was looking at the .net generic collections like ICollection, IEnumerable to see any that can support bidirectional navigation with methods like MoveNext, MovePrevious. Is there one?
wonderful world
  • 10,969
  • 20
  • 97
  • 194
0
votes
1 answer

Mapping from Tuple to ICollection

Ok so I get data from mySql and it comes back as a ReadOnlyCollection>. Now I have to map from this to my Audit and AuditItem classes. The Audit part is working like so: return…
Bobo
  • 976
  • 2
  • 10
  • 25
0
votes
1 answer

WCF serialization and IEnumerable vs ICollection inheritance

I am aware about the problem when creating custom collections that inherits from List or ICollection with additional custom properties: public class MyCollection: List { public string MyCustomProperty { get; set; } } As I know, such…
Alex Dn
  • 5,465
  • 7
  • 41
  • 79
0
votes
1 answer

ASP MVC3 - Editor Template returning null values to controller on post back

I've been struggling with a project for a couple days now, and in my current iteration I've decided to use an Editor Template. The original issue arose from a master table linked to a secondary table via a foreign key in SQL. In ASP MVC, the…
NealR
  • 10,189
  • 61
  • 159
  • 299
0
votes
2 answers

Adding to ICollection of type entity issue

Can some one help Not sure what I am doping wrong: in my controller: [HttpPost] public ActionResult SaveRecommendedUserDetails(RecommendAFriendViewModel model) { //List entityGroups = new List(); …
charlie_cat
  • 1,830
  • 7
  • 44
  • 73
0
votes
1 answer

Removing object from virtual collection or Moving to a different one in Entity Framework Code First

I have an object with a self referencing parent child relationship: [Table("Content")] public class Content { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int ContentID { get; set; } public string Text…
Alex C
  • 16,624
  • 18
  • 66
  • 98
0
votes
2 answers

Add single entry to ICollection dynamically one at a time (MVC4 EF)

I'm having a hard time wrapping my head around this issue: Is there a way to add a single entry to an ICollection? One at a time, persisting the data to the database for each entry added? Here is my specific situation: I have a Test Model: public…
nycfdtd
  • 404
  • 7
  • 23