Home

data grid & projections?

Can I write a projection & have LinqPad produce the link to the projection in the grid results? Like it produces on FKs:

Like this: https://stackoverflow.com/a/23794102/185123 but w/ the grid view.

Comments

  • The OnDemand extension method might help. This creates a DumpContainer that lazily expands a sequence.

    Eagerly:

    Customers.Select (c => new { c.ID, c.Name, Purchases = Purchases.Select (p => p.Description).OnDemand()  })
    

    Lazily (we need to ensure that LINQ-to-SQL does not include the projection in the expression tree):

    Func<Customer, DumpContainer> projection = c => c.Purchases.Select (p => p.Description).OnDemand();
    Customers.Select (c => new { c.ID, c.Name, Purchases = projection(c) }).Dump();
    

    or:

    void Main()
    {
        Customers.Select (c => new { c.ID, c.Name, Purchases = Projection(c) }).Dump();
    }
    
    static DumpContainer Projection (Customer c) => c.Purchases.Select (p => p.Description).OnDemand();
    
Sign In or Register to comment.