O'Reilly logo

LINQ for Visual C# 2008 by Fabio Claudio Ferracchiati

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1.9. Query Evaluation Time

It is important to understand when the query is evaluated at run time. In Listing 1-1 nothing happens in query execution until the ObjectDumper's Write method is called. Listing 1-8 looks at the code behind this method:

Example 1-8. The Core Method of the ObjectDumper Helper Class
private void WriteObject(string prefix, object o) {
  if (o == null || o is ValueType || o is string) {
    WriteIndent();
    Write(prefix);
    WriteValue(o);
    WriteLine();
  }
  else if (o is IEnumerable) {
    foreach (object element in (IEnumerable)o) {
      if (element is IEnumerable && !(element is string)) {
        WriteIndent();
        Write(prefix);
        Write("...");
        WriteLine();
        if (level < depth) {
          level++;
          WriteObject(prefix, element);
          level--;
} } else { WriteObject(prefix, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required