Why do not you identify the type and identification of the source for the client?

On page 220, the C # version 5.0 specification specification says:

It is important ... to ensure that the result of the query expression is never the original object, as this would reveal the type and source identifier for the request client.

Why would it be problematic to identify the type and identifier of the source for the request client?

As an example, a form request expression is from c in customers select cconverted to customers.Select(c => c)instead of simply customers.

In the above case, it seems to me that returning to the customerscustomer would be as good as returning the results customers.Select(c => c). Why is this not so?

+4
source share
2

, , . , , :

class C 
{
  private List<int> myList = new List<int>();
  // Only the code in C can add items to the list.
  public IEnumerable<int> Items 
  {
    get
    {
      return from item in myList select item;
    }
  }
}

, C. ?

((List<int>)c.Items).Add(123);

, ! .

, List<int> . , , , .

, LINQ , , , , , . , " ". , , .

. :

http://blogs.msdn.com/b/ericlippert/archive/2008/05/12/trivial-projections-are-usually-optimized-away.aspx

+9

, , :

var data=(from c in customers select c);
if (something)
  data=data.Where(somethingelse);

, , . var data, , .

+1

All Articles