ienumerable

Can I guarantee insertion order of IEnumerables over WCF?

If I have a WCF service which accepts an IEnumerable as a parameter to a function, is the order that I look up the elements guaranteed to be the same as they were added to the collection? (Or at least the same order they were sent across the wire?) If not, is there a way that I can guarantee the order, such as defining it in the service...

LINQ query expressions that operate on types (monads?) other than IEnumerable<T> -- Possible uses?

I'm reading the book Real-world functional programming by Tomas Petricek and Jon Skeet and I'm having a hard time digesting the section on computation expressions1) (aka monads). Through this book, I learnt that contrary to my previous experiences LINQ query expressions aren't restricted to IEnumerable<T>, but can work on other custom...

Error message regarding IEnumerable.GetEnumerator().

I get this error message and I can't figure out why! Error 1 'Exo5Chap12.ShortCollection<T>' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'Exo5Chap12.ShortCollection<T>.GetEnumerator()' cannot implement 'System.Collections.IEnumerable.GetEnumerator()' because it does not have the matching ...

How does one avoid "Value restriction" errors with F#'s Seq.cast?

I see that Seq has a cast function from IEnumerable to Seq, but how do I get it to work? open System.Text.RegularExpressions;; let v = Regex.Match("abcd", "(ab)");; Seq.cast (v.Captures);; This produces, error FS0030: Value restriction. The value 'it' has been inferred to have generic type val it : seq<'_a> Either define 'it' as ...

Retrieving selected data from DataGrid with IEnumerable<IDictionary> (Silverlight)

I have an application that can dynamically load data into a DataGrid. What's needed is an object of IEnumerable<IDictionary>, and a List<Dictionary<string,object>> is supplied (each Dictionary in the list has exactly the same keys). The data is loaded into the DataGrid and shown, but now I want to retrieve the data the user has clicked ...

Is this GetEnumAsStrings<T>() method reinventing the wheel?

I have a number of enums and need to get them as List<string> objects in order to enumerate through them and hence made the GetEnumAsStrings<T>() method. But it seems to me there would be an easier way. Is there not a built-in method to get an enum like this into a List<string>? using System; using System.Collections.Generic; namespa...

Can't add/remove items from a collection while foreach is iterating over it

If I make my own implementation of IEnumerator interface, then I am able ( inside foreach statement )to add or remove items from a albumsList without generating an exception.But if foreach statement uses IEnumerator supplied by albumsList, then trying to add/delete ( inside the foreach )items from albumsList will result in exception: cl...

How Array of our custom classes work with foreach without implemented IEnumerable ?

Hello everybody This long title already contain all my question so i just want to give example MyClass[] array How this array work with Foreach without implement IEnumerable interface's method ? ...

Form with list of checkboxes (best practices)

I have a view that allows the user to make a selection from an IEnumerable. The way I'm doing it now is to give each checkbox the id of the item and work with the form collection at the controller's side. I seem to remember there to be a better way but can't remember how anymore. Are there any better practices? ...

sort Ienumerable list

I have the following list IEnumerable<Car> cars The Car object has a model and a year. I want to sort this list by model and then year (within model) what is the best way of doing this ? ...

Why does not IDictionary (non-generic) inherit from IEnumerable<DictionaryEntry>?

IDictionary<TKey, TValue> inherits from IEnumerable<KeyValuePair<TKey, TValue>>, but IDictionary for some reason doesn't inherit from IEnumerable<DictionaryEntry>. I wonder why? I hate to write this ugly .OfType<DictionaryEntry>() every time when I need to make a query against an IDictionary. ...

How to cast list to enumerable

I've got a problem with the following code: public IEnumerable<ISession> GetSessions() { // ... using (ProvaDbEntities DBEntities = new ProvaDbEntities(Utilities.ToEntitiesConnectionString())) { ObjectQuery<session> sessions = DBEntities.session; IEnumerable<session> q1 = from session in sessions ...

IEnumerable DependencyProperty throws errors when set in XAML

I have a custom control Workspace that inherits from Control and within it is a DependencyProperty that I need to contain a user-specified IEnumerable<IFoo> (I have also tried making it an non-generic IEnumerable). Public Shared ReadOnly FoosProperty As DependencyProperty = DependencyProperty.Register("Foos", GetType(IEnumerable(Of IFo...

Syntax error when performing OrderBy<T> on an IEnumerable List

The error message I receive is: At least one object must implement IComparable The code causing this is below: private static IEnumerable<Result> setOrderBy(IEnumerable<Result> value, string order) { if (order.Equals("ASC")) { //value = value.OrderBy(c => c, new SearchService.ResultComparer<Attribute>()); value...

Getting a property from a class as a property of T in IEnumerable<T> for rdlc

I'm trying to use the DataSet from Entity Framework for RDLC. The entity is something like this: Department: DepartmentId Name Employee: EmployeeId DepartmentId -> FK to Department Name When I'm iterating the employees, is it possible get the department name? I've tried some things like =Fields!Department.Value.Name.Value or =Field...

Return CopyMost in LINQ

I am not sure if CopyMost is the correct term to use here, but it's the term my client used ("CopyMost Data Protocol"). I have a set of data: Increment Value .02 1 .04 1 .06 1 .08 2 .10 2 I need to return which Value occurs the most "CopyMost". In this case, the value is 1. Rig...

accessing C# base class in iterator causes ReSharper warning

I have two classes, GenericList and SpecificList, where SpecificList inherits from GenericList. GenericList implements IEnumerable<GenericItem> and SpecificList implements IEnumerable<SpecificItem>. SpecificItem inherits from GenericItem. I have to implement GetEnumerator in both GenericList and SpecificList since they implement IEnum...

Linq and DBNull - Getting error

Hi All, I'm getting an error when selecting from a rows.AsEnumerable(). I am using the following code... var rows = ds.Tables[0].AsEnumerable(); trafficData = rows.Select(row => new tdDataDC { CalculationCount = row.Field<Int64>("biCalculationCountSeqID") , Zone =...

Linq To Xml datasource for grid view is not working. The grid show no rows

Hi All, I'm getting some Xml back from a service. I would like it to be the datasource of a grid view on my aspx page. Here is a sample of the Xml <?xml version="1.0" encoding="utf-16" ?> <ArrayOfTripTollCompleteDC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <TripTollC...

IEnumerable yield return combined with .AsParallel()

I've written some code to try and describe my concern: static void Main(string[] args) { IEnumerable<decimal> marks = GetClassMarks(); IEnumerable<Person> students = GetStudents(); students.AsParallel().ForAll(p => GenerateClassReport(p, marks)); Console.ReadKey(); } GetClassMarks uses yield return in it from my weir...