Convert DataTable to IEnumerable

There’s also a DataSetExtension method called “AsEnumerable()” (in System.Data) that takes a DataTable and returns an Enumerable. See the MSDN doc for more details, but it’s basically as easy as: dataTable.AsEnumerable() The downside is that it’s enumerating DataRow, not your custom class. A “Select()” LINQ call could convert the row data, however: private IEnumerable<TankReading> ConvertToTankReadings(DataTable … Read more

Casting IEnumerable to List

As already suggested, use yourEnumerable.ToList(). It enumerates through your IEnumerable, storing the contents in a new List. You aren’t necessarily copying an existing list, as your IEnumerable may be generating the elements lazily. This is exactly what the other answers are suggesting, but clearer. Here’s the disassembly so you can be sure: public static List<TSource> … Read more

Chart of IEnumerable LINQ equivalents in Scala? [duplicate]

I am only listing out the equivalents of functions from Enumerable<A>. This is incomplete as of now. I will try to update this later with more. xs.Aggregate(accumFunc) -> xs.reduceLeft(accumFunc) xs.Aggregate(seed, accumFunc) -> xs.foldLeft(seed)(accumFunc) xs.Aggregate(seed, accumFunc, trans) -> trans(xs.foldLeft(seed)(accumFunc)) xs.All(pred) -> xs.forall(pred) xs.Any() -> xs.nonEmpty xs.Any(pred) -> xs.exists(pred) xs.AsEnumerable() -> xs.asTraversable // roughly xs.Average() -> xs.sum … Read more

Correct, idiomatic way to use custom editor templates with IEnumerable models in ASP.NET MVC

After discussion with Erik Funkenbusch, which led to looking into the MVC source code, it would appear there are two nicer (correct and idiomatic?) ways to do it. Both involve providing correct html name prefix to the helper, and generate HTML identical to the output of the default EditorFor. I’ll just leave it here for … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)