Linq in Preprocess query to sum values in related entity RRS feed

  • Question

  • Hello all,

    Can you please point out what is wrong with the query below?

    Private Sub CurrentStock_PreprocessQuery(ByRef query As System.Linq.IQueryable(Of LightSwitchApplication.accInventoryItem)) query = From i In accInventoryItems Where i.IsDiscontinued = False Select New With { _ .Item = i.ItemName, _ .Manufacturer = i.Manufacturer, _ .Supplier = i.Supplier, _ .StockLevel =i.accInventoryMovement.Sum( _

    Function(m As accInventoryMovement) _


    } End Sub End Class

    What I am hoping to achieve is get the current stock from InventoryItems and Inventorymovements.

    I keep getting an error I do not understand:

    "Selecting the source element is the only supported selector.
    Parameter name: selector"

    Monday, April 15, 2013 1:31 PM