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
2 answers

Collection of key-value pairs where only key type is known

I want a collection class of key-value pairs, where ill know the key type at instantiation level but ill only know the value type when adding a new element to the collection. Consider a the code snippet below public class Collection where…
Aiden Strydom
  • 1,198
  • 2
  • 14
  • 43
0
votes
2 answers

How to use AutoMapper to Map ManytoMany relationship

How can I use automapper to map ICollection property in my model class. Here is example: Mapper.CreateMap() .ForMember(dst => dst.UserId, opts => opts.MapFrom(src => src.UserId)) …
Almir
  • 11
  • 2
0
votes
1 answer

Why my ICollection is always empty?

I am trying to reach a foreach but my program never gets inside because my ICollection Coletores is always empty even if I put a lot of stuff in there. The code where I want to get inside and it is always empty (I want to get inside the second…
Gustavo Mendonça
  • 1,925
  • 3
  • 15
  • 26
0
votes
2 answers

Get Count on Entity with ICollection that has specific property value

I have a Model called Renders. public class Render { public int RenderId { get; set; } public string ClientName { get; set; } public string Title { get; set; } public ICollection Comments { get; set; } } And a collection…
Eric Bishard
  • 5,201
  • 7
  • 51
  • 75
0
votes
1 answer

Usage of Hashset to initialize objects

I am in the learning curve of entity framework. I follow the tutorials in the entity framework in msdn. In the sample, entities are defined as follows; public class Department { public Department() { this.Courses = new…
Akhil
  • 1,918
  • 5
  • 30
  • 74
0
votes
1 answer

How add an annotation on all properties of EF generated entities which identifies a database relation with the T4 template?

When I update model from database on entity framework, it creates the entities with its members: public string COLUMN { get; set; } and, if the entities has relations, it adds something like this: public virtual ICollection
0
votes
1 answer

Serializing an ICollection to JSON

I am trying to serialize an ICollection to JSON and pass it to my JS via hidden field on my HTML. So far I have tried: @Html.HiddenFor(model => JsonConvert.SerializeObject(model.Details), new { Id = "WorkOrderDetails" }) // also tried…
Guillermo Sánchez
  • 143
  • 1
  • 3
  • 15
0
votes
0 answers

IEnumerable interface definition

I took a look at the definition of the IEnumerable interface public interface IEnumerable { // Summary: // Returns an enumerator that iterates through a collection. // // Returns: // An…
Lamloumi Afif
  • 8,941
  • 26
  • 98
  • 191
0
votes
1 answer

How can I dynamically access user control attributes?

Im trying to create a "user control menu" where links to a page's usercontrols are placed at the top of the page. This will allow me to put several usercontrols on a page and allow the user to jump to that section of the page without scrolling so…
rahkim
  • 911
  • 2
  • 9
  • 17
0
votes
1 answer

How to get the key of an OrderedDict at a given index?

I'm seemingly unable to find a quick solution for an apparently simple problem: I have a C# OrderedDict, and, utilizing prior knowledge of the order, want to retrieve a key at a certain position. OrderedDict.Keys returns an ICollection object, but I…
fbmd
  • 730
  • 6
  • 22
0
votes
0 answers

Error when deserializing JSON list into ICollection in C#

I have three projects : App.Models: Contains object interfaces. App.WebAPIService: RESTFul API service using JSON. App.Client: WPF application that communicates with RESTful API Service. I use Entity Framework to create interfaces and…
Amandine
  • 1
  • 1
0
votes
1 answer

working with Entity Framework ntier - convert list to icollection error

Below is what I am trying to do. I am using Entity Framework 6 and I have a DataLayer Object that I am passing up the layers to a BusinessData Object. Basically get the object from the database and pass its values to a new object that mirrors it in…
0
votes
3 answers

Ordering a linq list based on a property of a child class

I have the following class: public class CourseSection { [Key] public int CourseSectionID { get; set; } public int CourseID { get; set; } public string Title { get; set; } public virtual ICollection
Jay
  • 3,012
  • 14
  • 48
  • 99
0
votes
2 answers

How to initialize my Model

Firstly, I'd like show you my model. public class Blog { [Key] public int BlogID { get; set; } public System.Nullable LastModified { get; set; } public System.Nullable AidID { get; set; } public virtual BlogAid…
robin521
  • 56
  • 1
  • 9
0
votes
1 answer

How to create an ICollection with TModel?

So I have a class called Repository which holds this method: public IEnumerable UpdateOrCreate(ICollection itemsToUpdate) where TModel : EndpointModelBase { //Do Stuff } How can I call this method with the…
brian4342
  • 1,265
  • 8
  • 33
  • 69