Converting a Linq query into it parts RRS feed

  • Question

  •      I have the following Linq query:

    var allItems = from matrix in dc.ItgCustomerProductMatrixes
    from fp in dc.FinancialPlans
    join vp in dc.VolumePlans on new { part0 = matrix.PlanningBrokerId, part1 = matrix.PlanningCustomerId, part2 = matrix.FinPlanPrdId, part3 = matrix.PackageGroupId } equals new { part0 = (System.Nullable<System.Int32>)vp.PlanningBrokerId, part1 = (System.Nullable<System.Int32>)vp.PlanningCustomerId, part2 = vp.FinPlanPrdId, part3 = (System.Nullable<System.Int16>)vp.PackageGroupId } into join1
    from vp in join1.DefaultIfEmpty()
    where vp.MonthSeqId >= fp.FromMonthSeqId
    && vp.MonthSeqId <= fp.ToMonthSeqId
    && fp.Id == finId
    orderby vp.MonthSeqId
    group vp by new { Id = -1, Description = "Total Volume", MonthSeqId = vp.MonthSeqId, Locked = vp.Locked, OrderQty = vp.CorporateAdjustedQuantity } into gp
    select new
    Id = (
    Description = gp.Key.Description,
    MonthSeqId = gp.Key.MonthSeqId,
    Locked = gp.Key.Locked,
    Quantity = gp.Sum(x => x.CorporateAdjustedQuantity)

        What I want is the same query written calling the various methods instead of in the Linq query stynax, i.e. instead of join I would use .Join(WWWW, XXX, YYYY, ZZZZ).

        The reason that I want this is because I want to be able to customize different parts of the query, for example I need to change the Group By section, you see right now the group By is hard coded with a -1 ID, but what I really want is to customize this, so that it will group by whatever I want and to do that I need to the query in it's pieces, so that I can modify the individual sections

    Thursday, September 11, 2008 5:10 PM