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

MVC4 EF DB First - How to access a models foreign key (ICollection)

I created a MSSQL database with tables containing foreign keys. I then created a new MVC 4 web application. I used Entity Framework to generate my controllers/models/views. In the models, tables that were linked using foreign keys appear as…
0
votes
1 answer

Unable to initialize list property of ASP MVC3 ViewModel

Below are two ViewModels we use in an ASP MVC3 site we're building. In the code below that, I am trying to populate the TradingPartners IList property of the AgentIdDetail property of the AgentWithTraining variable named bigAgent. To better…
NealR
  • 10,189
  • 61
  • 159
  • 299
0
votes
1 answer

How to provide a "List" of removed/original Items for ICollection Childs

Hi i want to do something like SomeCollection.GetChanges(ItemState.Deleted) and the result should be all removed Items You can do such things with DataTable. But how to implement this in an List or ObservableCollection? Is there already a…
WiiMaxx
  • 5,322
  • 8
  • 51
  • 89
0
votes
4 answers

Adding a Collection of Interfaces to an Interface

I'm trying to wrap my head around interfaces. I keep stumbling on implimenting something like this: public interface IFoo { ICollection Bars { get; set; } //some other properties } public interface IBar { //some…
Billdr
  • 1,557
  • 2
  • 17
  • 30
0
votes
2 answers

IList throws Null Reference Exception when adding values

I have a class: public class ClientModelData { public int clientID { get; set; } public IList LocationIDs { get; set; } } When I call it: ClientModelData obj = new ClientModelData(); obj.LocationIDs.Add(1); It throws an…
Sohail
  • 45
  • 1
  • 6
0
votes
2 answers

Handle Icollection within controller and View

I have a 2 samlple model like this (I have enterd intered the fields whicj I want only ) [Table("TripAllocation", Schema = "dbo")] public class TripAllocation { public int TripAllocationId { get; set; } public ICollection
Anuradha
  • 1
  • 2
0
votes
1 answer

PagedDataSource not getting datasource

I cannot get a PagedDataSource to use an IEnumerated collection of EntityCollection objects as a datasource. The PagedDataSource accepts the collection as a datasource but then I can't use basic properties like CurrentPageIndex and IsLastPage…
Matt Foxx Duncan
  • 2,074
  • 3
  • 23
  • 38
0
votes
1 answer

Using 'OR' in a return from ActiveRecordLinq statement

I am working on an existing online library of MP3 files. One part of the code looks for files in the database that contain a certain string in the series title. public ICollection ListTruthAndLifeSeries() { return (from f in…
Stephanie Wilson
  • 55
  • 1
  • 1
  • 7
0
votes
2 answers

How to create Callback Event on ICollection in C# - for batching

Is there a way to create a callback function that fires when a list object (any Class implementing the ICollection interface of C#.NET) reaches a certain capacity (number of items in the list)? I would like an event to fire when my list object has 5…
Saher Ahwal
  • 9,015
  • 32
  • 84
  • 152
0
votes
5 answers

How do I add to an ICollection property when iterating object type?

I have need to add to an ICollection property of a class of which I have an IEnumerable of. Here is a complete program which illustrates the problem: using System; using System.Collections.Generic; using System.Linq; namespace…
Russ Clark
  • 13,260
  • 16
  • 56
  • 81
0
votes
0 answers

Why Datetime property value changes when I retrieve it from a List?

I have a class called Job and that encapsulates an object of another class called SelectedItem which has a DateTime property called ItemDate; class Job { private SelectedItem m_SelectedItem = null; public Job() { } public SelectedItem…
Azhar Khorasany
  • 2,712
  • 16
  • 20
0
votes
0 answers

How can I save an Icollection in an object?

I have the following code: ICollection samples = new Collection(); samples.Add(sample1); samples.Add(sample2); Order record = scope.DbContext.Orders.AddNew(new Order { Name = GenerateName("Order"), Samples = samples }); When…
Niek de Klein
  • 8,524
  • 20
  • 72
  • 143
-1
votes
2 answers

Why is indexing used in in the ICollection Interface implementation example in Microsoft's documentation, if you cannot use it?

I'm trying to understand how to implement generic collections and the IEnumerator interface; I'm using the Documentation provided to do so. In the given example the enumerator's method MoveNext() is implemented as follows: public bool MoveNext() { …
-1
votes
1 answer

Is it smart to replace ICollection with ObservableCollection wpf ef

I'm a beginner with wpf app building and entity framework. I'm building my first wpf app, I found out I should have replaced my auto-generated ICollection with ObservableCollection. The problem is that I already did most of my code so far but am…
-1
votes
1 answer

Passing multiple values to same column in the lambda query C#

Hello I am trying to create a query where in the where clause i need to pass multiple values to the same column and i have built a query using string builder. My actual Lambda query was crentitiesbkp.Filter = obj => { SPFetchCREntity entity…
Sam King
  • 75
  • 1
  • 12
1 2 3
18
19