ienumerable

Can't bind to IEnumerable implementation using yield

I have a class encapsulating a bunch of collections. I would like to bind this class to a listbox to display the items in the collections. The class implements IEnumerable. When the listbox is displayed I am expecting the IEnumerable.GetEnumerator method to be called. It is however not when the GetEnumerator method uses the yield keyword...

c# complex objects comparison

Hi Everyone, public class SecurityMaster : EntityObject { public string BondIdentifier { get; set; } public string Description { get; set; } public EntityCollection<SecurityMasterSchedules> SecurityMasterSchedules { get; set} } public class SecurityMasterSchedules :EntityObject { public string BondIdentifier { ...

Using 'Contains' Clause Like 'IN' SQL Clause in Entity Framework

I am working on a tag cloud application. There are 3 database tables. Content: ContentID, Text Tag: TagID, Name TagRelation: TagRelationID, TagID, ContentID The code below is wrong. Because 'Contains' clause doesn't take a list of parameters like the 'IN' SQL clause. Is there an alternative clause that I can use to make this code wor...

Strongly-typed method interface using yield return

I really enjoy to be able to do this in C# : IEnumerable GetThePizzas() { yield return new NewYorkStylePizza(); yield return new SicilianPizza(); yield return new GreekPizza(); yield return new ChicagoStylePizza(); yield return new HawaiianPizza(); } Whereas in Java I would have done it like that : Collection<Pizz...

Why the content of the pure IEnumerable is invisible for WPF DataGrid?

Let's say I have a datagrid with itemsource binded to property Collection, which is for example IEnumerable. Of course I wrote appropriate getter and setter for it. Now, when I assign to this property (Collection) just IEnumerable (as the result of some method), like: Collection = FooMethod(); // FooMethod returns IEnumerable<MyClass> ...

How to invoke System.Linq.Enumerable.Count<> on IEnumerable<T> using Reflection?

I have a bunch of IEnumerable Collections which exact number and types is subject of frequent changes (due to automatic code generation). It looks something like this: public class MyCollections { public System.Collections.Generic.IEnumerable<SomeType> SomeTypeCollection; public System.Collections.Generic.IEnumerable<OtherType>...

Multiple enumerators for an IEnumerable

I have a custom made collection that has many modes of objects generations inside of it. It can generate everything, one object at a time or N objects at a time. I would like to have the option to switch between implementations of generation on runtime, and even maybe create new ones. I am looking for something with this kind of syntax: ...

What is the difference between IEnumerable and arrays?

Will anyone describe IEnumerable and what is difference between IEnumerable and array and where to use it.. all information about it and how to use it. ...

Why doesn't IEnumerable<T> implement Add(T)?

Just now find it by chance, Add(T) is defined in ICollection<T>, instead of IEnumerable<T>. And extension methods in Enumerable.cs don't contain Add(T), which I think is really weird. Since an object is enumerable, it must "looks like" a collection of items. Can anyone tell me why? ...

Is IEnumerable required to use a foreach loop?

I was wondering, when exactly can I use the foreach loop? Do I have to implement IEnumerable? ...

Convert IEnumerable<XElement> to XElement

The return type of my query is IEnumerable<XElement>. how can i convert the resultant data to XElement type? is it possible? could some body help me to understand this. var resQ = from e in docElmnt.Descendants(xmlns + Constants.T_ROOT) .Where(x => x.Attribute(Constants.T_ID).Value == "testid") s...

Alternative to IEnumerable<T>.Skip(1).Take(1).Single()

I am having a difficult time with a seemingly easy and embarrassing problem. All I want is the next element in an IEnumberable without using Skip(1).Take(1).Single(). This example illustrates the basic problem. private char _nextChar; private IEnumerable<char> getAlphabet() { yield return 'A'; yield return 'B'; yield retur...

LINQ Convert IEnumerable<string> to List<ulong>

I have the following code: var personIds = from player in myPlayers select player.person_id; where personIds is an IEnumerable<string> that I'd like to convert to List<ulong>, since person_id is convertable via Convert.ToUInt64() Is this easily done in LINQ? ...

Find the highest number in a set to be rounded down, and round it up instead

As the title describes, I have a set of objects - call them Allocations - which contain a description & a number. All numbers in the set add up to 100%, but for display purpose I sometimes round to a whole percent. In some edge cases, having rounded the numbers I end up with 99%. Example: Description | Actual | Rounded ==============...

Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<>

Hi All, Is there any specific reason why indexing is not allowed in IEnumerable. I found a workaround for the problem I had, but just curious to know why it does not allow indexing. Thanks, ...

Intersection of 6 List<int> objects

Hi, As I mentioned in the title I've got 6 List objects in my hand. I want to find the intersection of them except the ones who has no item. intersectionResultSet = list1. Intersect(list2). Intersect(list3). Intersect(list4). Intersect(list5). Intersect(list6).ToList(); When one of them has no item, normally I...

IEnumerable -- how non-empty collection can be empty at the same time?

I cannot figure this out. The workflow of passing IEnumerable<T> (T is some my class, but it is not relevant here) basically looks like this: var a = GetEntireCollection(); // so I get IEnumerable<T> ... var b = a.Where(condition1); ... var c = b.Where(condition2); ... So I filter out more and more items from the collection, finally I...

Dont understand IEnumerable<T>

Hi, I'm having alot of trouble with my code. When I compile I get the following error: 'Ecommerce.DataHelpers.ProductNodeLoader' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'Ecommerce.DataHelpers.ProductNodeLoader.GetEnumerator()' cannot implement 'System.Collections.IEnumerable.GetEnumerator...

C#/.NET/WPF: Obtaining subsets from LINQ, rather than the IEnumerable

I have some trivial code that looks like this: SortedDictionary<String, long> d = new SortedDictionary<String, long>(); // d is then populated with an expensive time-consuming process ListBox lb = new ListBox(); lb.ItemsSource = d; // THIS WORKS GREAT Now what I'd like to do is dynamically show a ...

LINQ - IEnumerable vs List - What to Use? How do they work?

Hello everybody ::- ). I have some doubts over how Enumerators work, and LINQ. Consider these two simple selects: List<Animal> sel = (from animal in Animals join race in Species on animal.SpeciesKey equals race.SpeciesKey select animal).Distinct().ToList(); or IEnumerable<A...