Is it possible to do something like this?
var strings = ConfigurationManager.ConnectionStrings; var names = (from d in strings select new ConnectionName(d.Name));
Yes, but because
ConnectionStrings does not implement a strongly typed
IEnumerable, you have to tell LINQ what type the collection contains.
from ConnectionStringSettings d in strings or
You have to Cast it to its type as it is
IEnumerable<T> See Enumerable.Cast :
Casts the elements of an IEnumerable to the specified type.
var t = from c in connectionString.Cast<System.Configuration.ConnectionStringSettings>() select c.Name;