locked
How do I replicate the group by and having clauses? RRS feed

  • Question

  • I have this query;

    public TrainingListViewModel(List<int> employeeIdList)
           
    {
               
    this.EmployeeOtherLeaveItemList =
                   
    CacheObjects.AllEmployeeOtherLeaves
                   
    .Where(x => x.OtherLeaveDate >= Utility.GetToday() &&
                        x
    .CancelDate.HasValue == false &&
                        x
    .OtherLeaveId == Constants.TrainingId)
                   
    .OrderBy(x => x.OtherLeaveDate)
                   
    .Select(x => new EmployeeOtherLeaveItem
                   
    {
                       
    EmployeeOtherLeave = x,
                       
    SelectedFlag = false
                   
    }).ToList();
           
    }

    This works but I want to change it to join to a list collection of

    int EmployeeIds;

    So List<int> EmployeeIdList joins to x.EmployeeId in

    CacheObjects.AllEmployeeOtherLeaves.

    What I want the new join to do is return the date value of where the date exists for

    each of the EmployeeId in the OtherLeaveDate EmployeeIdList collection.

    So for EmployeeId I have D1, D5, D6, D10

    for EmployeeId 2 have D1, D5, D6, D10, D12

    for EmployeeId 3 have D3, D5, D6, D10, D12

    Then return D5 and D10 where D stands for date.

    Thank you.

    Sunday, October 21, 2012 11:37 AM

All replies

  • I'm not clear about your issue? Do you mean you want to join EmployeeOtherLeaveItemList  with EmployeeIds, and query out the records of EmployeeOtherLeaveItemList  which contains Id in EmployeeIds?
    Tuesday, October 23, 2012 3:13 AM
  • Hi arame3333,

    Could you please clarify @Doraemon 3's concern? I'm also not clear about the issue.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, October 25, 2012 2:14 AM