Search code examples
c#linq-to-sqliqueryableentitysetdebuggervisualizer

Where is EntitySet<T>'s "Results View"?


When looking at a linked EntitySet<T> of a LINQ to SQL mapped entity, I see the following:

EntitySet debug view

I'd like to see the following (achieved by using the .AsQueryable() extension method) so that I can click the little refresh icon and see the content:

alt text

Why can't I see the Results View on a regular plain EntitySet<T>?

Also, I've noticed that on this MSDN page it says:

In LINQ to SQL, the EntitySet<TEntity> class implements the IQueryable interface.

From what I can see, EntitySet<TEntity> doesn't inherit from either IQueryable nor IQueryable<T>. So what's up with that claim?


Solution

  • You'll find the answer to this question

    The results view only works for collections which meet the following conditions

    1. Implement IEnumerable or IEnumerable (VB.Net only works for IEnumerable)
    2. Do not implement IList, IList, ICollection or ICollection (C# restriction only)
    3. Do not have a DebuggerTypeProxy attribute
    4. System.Core.dll is loaded in the debugee process

    In particular #2, EntitySet<T> implement's IList<T> therefore the debugger won't show a "Results View" option.

    Using the AsQueryable extension method returns an object which only implements IQueryable and IEnumerable and therefore will show the "Results View" option.

    You can read more about the #2 in the answer given in the other question.