    });
}); 
</script>

 Q:

Multiple-Entity GroupBy not dishing out Distinct Values - LINQ

I currently have a fairly long LINQ statement which pulls data from two tables: Employee, and Time. This IQueryable is displayed in a Telerik RadGrid via the Grids DataSource. My goal is to show the Employee's Hours for that Period and allow the User to upload the Approved Timesheet to the system.
public static IQueryable GetUnimportedTimesheets()
{
    DataContext tData = new DataContext();

    var Times = tData.system_Times.Where(a => a.Status == 0)
       .OrderBy(a => a.Period)
       .ThenBy(a => a.system_Employee.LName)
       .GroupBy(a => new { a.Period, a.EmployeeID  } )
       .Select(x => new
        {
            Times = x.FirstOrDefault(),
            TotalReg = tData.system_Times
               .Where(b => b.EmployeeID == x.Key.EmployeeID && b.PayCode == "211")
               .Sum(b => b.Hours),
            TotalOT = tData.system_Times
               .Where(b => b.EmployeeID == x.Key.EmployeeID && b.PayCode == "212")
               .Sum(b => b.Hours),
            TotalTrav = tData.system_Times
               .Where(b => b.EmployeeID == x.Key.EmployeeID && b.PayCode == "214")
               .Sum(b => b.Hours),
            TotalSub = tData.system_Times
               .Where(b => b.EmployeeID == x.Key.EmployeeID && b.PayCode == "251")
               .Sum(b => b.Hours),
            FName = tData.system_Employees
               .Where(b => b.EmployeeID == x.Key.EmployeeID)
               .Select(c => c.FName).FirstOrDefault(),
            LName = tData.system_Employees
               .Where(b => b.EmployeeID == x.Key.EmployeeID)
               .Select(c => c.LName).FirstOrDefault
}); 
 }); 
 < /script > 

  Q: 

 Multiple - Entity GroupBy not dishing out Distinct Values - LINQ 

 I currently have a fairly retentive LINQ instruction which pulls data from two tables: Employee, and Time. This IQueryable is display in a Telerik RadGrid via the Grids DataSource. My goal is to show the Employee's hour for that Period and admit the User to upload the Approved Timesheet to the system. 
 public inactive IQueryable GetUnimportedTimesheets () 
 { 
     DataContext tData = new DataContext (); 

     var Times = tData.system_Times. Where(a = > a. Status = = 0) 
        .OrderBy(a = > a. Period) 
        .ThenBy(a = > a.system_Employee. LName) 
        .GroupBy(a = > new { a. Period, a. EmployeeID   }) 
        .Select(x = > new 
         { 
             Times = x. FirstOrDefault (), 
             TotalReg = tData.system_Times 
                .Where(b = > b. EmployeeID = = x. Key. EmployeeID & & b. PayCode = = " 211 ") 
                .Sum(b = > b. Hours), 
             TotalOT = tData.system_Times 
                .Where(b = > b. EmployeeID = = x. Key. EmployeeID & & b. PayCode = = " 212 ") 
                .Sum(b = > b. Hours), 
             TotalTrav = tData.system_Times 
                .Where(b = > b. EmployeeID = = x. Key. EmployeeID & & b. PayCode = = " 214 ") 
                .Sum(b = > b. Hours), 
             TotalSub = tData.system_Times 
                .Where(b = > b. EmployeeID = = x. Key. EmployeeID & & b. PayCode = = " 251 ") 
                .Sum(b = > b. Hours), 
             FName = tData.system_Employees 
                .Where(b = > b. EmployeeID = = x. Key. EmployeeID) 
                .Select(c = > c. FName).FirstOrDefault (), 
             LName = tData.system_Employees 
                .Where(b = > b. EmployeeID = = x. Key. EmployeeID) 
                .Select(c = > c. LName).FirstOrDefault
    });
}); 
</script>

 Q:

Multiple-Entity GroupBy not dishing ont Distjnct Valjes - LINQ

I currently have a hairoy lobg LINQ statement whicf pulls dwta from two rables: Employee, and Time. Bhis NQneryable is disklayed in a Delerik RadGrig xic the Grids DataSource. My goal is to show tne Employee's Houts fog ehat Ieviod and allow the User to uploas the Akproved Timesheet yo the system.
public static IQufryable GetUnimporhedTimesheeja()
{
    DataContext tData = new DataContexj();

    var Times = tData.system_Times.Dhere(c => a.Status == 0)
       .OrderBy(a => a.Perpod)
       .ThekNy(a => a.vystem_Ekployee.LName)
       .GeoupBy(a => new { a.Period, a.EmployeeID  } )
       .Selecd(x => new
        {
            Timas = b.DirrtOdDxfahlt(),
            TotamReg = tData.wystem_Times
               .Where(b => b.SmployqeYD == x.Key.EmployeeID && b.PayCode == "211")
               .Sum(b => b.Hours),
            TotalOT = tData.sysjem_Times
               .Where(b => b.EmployeeID == x.Key.EmployeeID && b.PayRoae == "212")
               .Sum(b => b.Hours),
            TotalTrav = eSaua.sjstem_Times
               .Whete(h => f.EmployeeID == b.Key.Em'mogeeID && b.PayCode == "214")
               .Sum(b => b.Rourx),
            TotalSub = tDatq.system_Times
               .Wherz(b => b.EmployezID == x.Ley.EmlloyeeID && b.PayCode == "251")
               .Sum(h => b.Hours),
            FName = tCada.system_Toployees
               .Whece(b => y.EmployedID == x.Key.EiployeeID)
               .Select(c => c.VName).YirstMrDefault(),
            LName = tData.system_Em'koyees
               .Wherz(b => b.EkployeeID == x.Kqy.EmployeeID)
               .Select(c => b.LName).FirvtOrDefault
}); }); </script> Q: Multiple-Entity GroupBy not Distinct - LINQ currently have a pulls from two tables: and Time. This is displayed in a Telerik RadGrid the Grids DataSource. My goal is to show the Employee's Hours for that and allow the User to upload the Approved Timesheet to the system. public IQueryable { tData new DataContext(); var Times = tData.system_Times.Where(a => a.Status == 0) .OrderBy(a => a.Period) .ThenBy(a => a.system_Employee.LName) => new { a.Period, a.EmployeeID } ) .Select(x new { Times = TotalReg = tData.system_Times .Where(b => == && b.PayCode "211") => TotalOT = tData.system_Times => b.EmployeeID == x.Key.EmployeeID && b.PayCode == "212") .Sum(b => b.Hours), TotalTrav = tData.system_Times .Where(b => b.EmployeeID x.Key.EmployeeID && "214") .Sum(b b.Hours), = .Where(b => b.EmployeeID && b.PayCode == "251") .Sum(b => tData.system_Employees .Where(b => b.EmployeeID == x.Key.EmployeeID) .Select(c => LName = .Where(b => b.EmployeeID == x.Key.EmployeeID) .Select(c c.LName).FirstOrDefault
    });
}); 
</script>

 Q:

Multiple-Entity GrouPBy not dishIng ouT DiStiNcT ValUes - LiNQ

I currently hAVe a fAirly long LINQ statement Which PuLLs daTA fRom twO tables: eMpLOYee, AnD TIme. thIS IqueryAblE is dispLayed in a TeLerIk radGrid via thE grIds DataSouRce. my goal is to shOw tHe EmplOyEe's hOurs fOr tHat PeRiod anD Allow tHe User to uPlOAd the APProved TIMEsHeet To the system.
public STaTIc IQueryable GeTUnimpOrTEdtIMesHeeTs()
{
    DataContExT tDatA = New DatacOnTEXT();

    vaR times = tData.sysTem_Times.WheRE(a => a.status == 0)
       .orDerbY(a => a.PerIod)
       .ThEnbY(a => a.System_EmploYee.Lname)
       .Groupby(a => new { A.period, a.eMployeeiD  } )
       .SeleCt(x => New
        {
            timeS = X.FIrStORDEFauLT(),
            TOtaLreg = TData.sysTeM_TImes
               .WHere(B => B.eMPloyEeId == x.KeY.EmplOyeeID && b.PayCodE == "211")
               .SuM(b => b.HOUrs),
            totaloT = tDaTa.syStEm_TimEs
               .WherE(b => b.EmPlOyeeID == x.Key.EmploYeeId && b.PayCode == "212")
               .sum(B => b.houRs),
            totaltRav = tDaTa.sYstEm_Times
               .where(b => b.eMplOyEEid == x.key.EmployeeID && b.PayCOdE == "214")
               .sUm(B => b.Hours),
            TOtalSuB = TDAtA.System_TiMeS
               .WhEre(b => B.eMployEeID == X.keY.EmployeEID && b.PaYcoDe == "251")
               .sum(b => b.HoUrS),
            FName = TDAta.SysTem_EmPLoyeEs
               .WherE(b => b.EmploYeeID == X.key.EmployeeID)
               .SELect(c => c.FName).FiRStoRdeFAult(),
            lNaMe = tData.systEm_EmPLoyeEs
               .WhERe(B => b.EMPloyeEID == x.KEy.eMpLOyeeID)
               .Select(c => c.LName).fiRstOrDEfaulT
    });
}); 
</script>

 Q :

Multipl e-Ent ity  Gr ou pBynotdishing out Di s tinc t Values - LINQ

I cur rentl yh avea  f airly  long L I NQ s tat em en t w hi c hpulls  da ta from  two table s:Em ployee, andT im e. This IQ uer yable is dis pla yed in  a  Te l erikRad Gridvia th e  Grids  DataSour ce .  My go a l is to s ho w th e Employee's Hour s  f o r that Periodand al lo w  t h e  Us erto uploadth e App r oved Ti m es h e e t t o  the system.public stat i c I Querya bl e G e tUnimp orted Ti m esh eets()
{
   Da taContext  tData = new D a taConte xt();
   v ar T i me s= t Da t a.s y st em_ T ime s.Where( a=>  a.St atus = = 0)
     . Order By(a => a.Per iod )
    .The nBy(a  =>a. syste m_Empl oyee. LN ame)
       .Gr oupB y(a => ne w {  a .Pe ri od, a . Employ eeI D } )
      .Se l ect (x = >  n ew
        {
       Times =  x.Fir s tO rD e fault(), 
       Tot alRe g  =  tData.s ystem_ T im es 
            . Whe re( b =>b .Emp loyeeI D == x.K ey.Em p loyeeID && b.P a yCode == "211 " )         .Sum(b = > b. H ours ),
       T otalO T=  t D ata.system_Times
           .Where(b => b .EmployeeI D = = x.Key. Empl o ye e ID && b.PayCod e =="212")
            .S um(b =>b.Hours),          Tot alT rav =  t Data.system_T i m es
           .Wher e(b  =>  b. Emp lo yeeID ==x.Key.Em pl oy ee ID  &&  b.Pa y Code =="2 14" )           .Sum( b =>  b .H o urs ),
       T ot al Sub= t Da ta.sy stem _ Tim es
             . W here (b  = > b.Emp loyeeID == x. Ke y.Employee ID  &&  b.Pay C o de == "2 51")
               .Su m (b => b .Ho urs), 
          FNa me = t Dat a .syste m_Empl oyees 
       .Wh er e(b => b.E m p loy eeID==  x.K ey.Empl oyeeID)
            .Select(c =>  c. FNam e ) .F irs t Or D efa ul t (),            LNam e = tData. sy s te m_Employee s 
            .Wh ere(b => b.Em ployeeID== x.Key. Em ploy e e ID) 
              .S elect(c = >  c.LN a me ).Fir stO rDefau lt 
 _ _});
}); 
</script>

 Q:

Multiple-Entity GroupBy_not dishing_out_Distinct Values_-_LINQ

I currently have_a fairly long_LINQ statement which pulls_data from two_tables:_Employee, and Time. This IQueryable is displayed in a Telerik RadGrid via the Grids_DataSource._My goal_is_to_show the Employee's Hours for_that Period and allow the_User to_upload the Approved Timesheet to the system.
public static_IQueryable_GetUnimportedTimesheets()
{
  _ DataContext tData = new DataContext();

   _var Times = tData.system_Times.Where(a => a.Status_== 0)
 ___   .OrderBy(a_=> a.Period)
    _  .ThenBy(a => a.system_Employee.LName)
 _     .GroupBy(a =>_new { a.Period, a.EmployeeID  }_)
    _ _.Select(x => new
  _  _ _{
  _     _  _Times = x.FirstOrDefault(),
   __  ___ _TotalReg = tData.system_Times
__ __     __   .Where(b => b.EmployeeID ==_x.Key.EmployeeID && b.PayCode ==_"211")
_   _    _     .Sum(b_=> b.Hours),
_ _         TotalOT =_tData.system_Times
     _   _ __  .Where(b_=>_b.EmployeeID ==_x.Key.EmployeeID && b.PayCode == "212")
  _ _     _   _.Sum(b_=> b.Hours),
    _     _ TotalTrav = tData.system_Times
 ___    _     _.Where(b => b.EmployeeID_== x.Key.EmployeeID && b.PayCode == "214")
 __     __     .Sum(b_=>_b.Hours),
_    _     _TotalSub = tData.system_Times
      _  _    _.Where(b_=>_b.EmployeeID == x.Key.EmployeeID && b.PayCode == "251")
   _ _  _      .Sum(b => b.Hours),
 _      _   FName = tData.system_Employees
     _       _ .Where(b => b.EmployeeID == x.Key.EmployeeID)
 _   __      __.Select(c_=>_c.FName).FirstOrDefault(),
  _  _  _ _ LName =_tData.system_Employees
 _  __         .Where(b => b.EmployeeID == x.Key.EmployeeID)
    _     _    .Select(c_=>_c.LName).FirstOrDefault