problem about icollection-Collection of common programming errors
Cort3z
casting asp.net-mvc-4 entity-framework-4.3 icollection
This is the datamodel I have:public class Team {[Key]public int Id { get; set;} [Required]public string Name { get; set; }[MinLength(1)]public virtual ICollection<User> Users { get; set; } }My issue is that when I later try to create a new Team (that has one user) I get the following issue when the context is saving.An unexpected exception was thrown during validation of ‘Users’ when invoking System.ComponentModel.DataAnnotations.MinLengthAttribute.IsValid. See the inner exception for deta
Sandy
c# generics c#-4.0 icollection
I am stuck with this simple looking code for over an hour now… I have few classes…and methods like this:abstract class ClassBase<SampleInterface> {//Some methods};public class ClassAction1: ClassBase<MyInterface> {//Some methods};public class ClassAction2: ClassBase<MyInterface> {//Some methods};class SomeClass { public void AddClassRange(ICollection<ClassBase<MyInterface>> range){foreach (ClassBase<MyInterface> ClassBase in range)AddClass(ClassBase);}publ
Konrad Morawski
c# list interface casting icollection
I have classT, implementing interfaceIBar.I have a variable list of type List<T>.Two questions for enhancing my understanding of the language:Why doesn’t this work?var foo = (ICollection <IBar>)list; // fails! How to work around it (if possible)?
GivenPie
c# asp.net database dataset icollection
I’m opening up a database query from the Northwind database for each item that my ShoppingCart entails. It is to take ProductID and UnitsInStock out from the Products table. After I take the two columns out from the database to save the data into a DataTabel ds. Then I compare to make sure the quantity user entered is less than the column units in stock in the database.theCart.Values is part of ICollections.I am gettign error: from my exception message: “There was a problem connecting to the dat
Joachim Sauer
collections ienumerable generics icollection
I have a method with an object parameter.public bool ContainsValue(object value)I found that converting the object to an IList works.IList<object> list = (IList<object>)value;However, converting it to a List does not.List<object> Ilist = (List<object>)value;I looked at the definition of both the IList and the List and they both seem to implement the Enumerator and Collection interfaces. I am wondering why List doesn’t work but IList does. Where in the framework does it
Éric
c# key-value icollection idictionary
I have a C# class that acts as a dictionary so I’m now in the process of supporting IDictionary.Everything is fine except for the properties Keys and Values:ICollection<TKey> Keys { get; } ICollection<TValue> Values { get; }I don’t have a collection of keys or values internally so I’m wondering how to provide these as a ICollection.My first attempt was to use the magic of “yield return” like this:ICollection<TValue> Values { get {for( int i = 0; i < nbValues; ++i ) {yield re
Web site is in building