Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate new Linq SelectMany extension method
    primarykey
    data
    text
    <p>I am using Linq.Dynamic. I have already added another SelectMany extension to all for creating a new anonymous object with the data. But, I have ran into another issue that I can not seem to solve. </p> <p>I want to have extension method chaining as follows, but using the dynamic methods:</p> <pre><code>var customerandorderflat = db.Customers .SelectMany(c =&gt; c.Orders.SelectMany(o =&gt; o.Order_Details, (ord, orddetail) =&gt; new { OrderID = ord.OrderID, UnitPrice = orddetail.UnitPrice }).DefaultIfEmpty(), (cus, ord) =&gt; new { CustomerId = cus.CustomerID, CompanyName = cus.CompanyName, OrderId = ord.OrderID == null ? -1 : ord.OrderID, UnitPrice = ord.UnitPrice }); </code></pre> <p>Ideally I would like to chain the dynamic SelectMany as follows:</p> <pre><code>db.Customers.SelectMany(c =&gt; c.Orders.SelectMany("Order_Details", "new(outer.OrderID, inner.UnitPrice)"), "new(outer.CustomerID, inner.OrderID)"); </code></pre> <p>Or something to that affect. The problem is that I can not get a signature to match.</p> <p>I have tried many different options to get it to allow chaining. But it just doesn't work. I am thinking ideally it would look like this:</p> <pre><code>public static IQueryable SelectMany(this IQueryable source, IQueryable innerExpression, string resultsSelector, params object[] values) </code></pre> <p>But, it doesn't recognize c => c.Orders as IQueriable. I also need to figure out how to do DefaultIfEmpty on the results to allow for LEFT JOINs.</p> <p>Please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload