4

I always confuse AsQueryable, AsEnumerable. When should I use them? Should I use AsQueryable to create a LINQ statement to make a filter according to attribute of xml or AsEnumerable?

[Serializable]
public class LogHandler : IConfigurationSectionHandler
{
    public object Create(object parent, object configContext, XmlNode section)
    {
        XmlAttributeCollection v = section.Attributes;
    }
}
Robaticus
  • 22,857
  • 5
  • 54
  • 63
uzay95
  • 16,052
  • 31
  • 116
  • 182
  • 1
    Check this thread - http://stackoverflow.com/questions/2876616/returning-ienumerablet-vs-iqueryablet – Stecya Mar 28 '12 at 12:52
  • Could you add some more detail about what you're trying to achieve in the code snippet that you posted? – Caleb Bell Mar 29 '12 at 17:33

1 Answers1

2

The primary difference is that the extension methods defined for IQueryable take Expression objects instead of Func objects, meaning the delegate it receives is an expression tree instead of a method to invoke. IEnumerable is great for working with in-memory collections, but IQueryable allows for a remote data source, like a database or web service.

Michael Schnerring
  • 3,584
  • 4
  • 23
  • 53