c# - Changing Rows to Columns in LINQ -


i have list displays recorded shown view using linq want record display shown view b.

also, using angularjs binding script using ng-repeat table display record.

i have included sample of code below.

view a:

enter image description here

view b:

enter image description here

code:

   public iqueryable<paygrossentitlement> getpayrollbyid(int payrollid, int schoolbranchid, int schoolid)           {               var query = x in _context.db.tbl_paygrossentitlement                           x.schoolid == schoolid && x.schoolbranchid == schoolbranchid && x.payrollid == payrollid && x.salarycomponentid !=6                           select new paygrossentitlement()                           {                               schoolid = x.schoolid,                               schoolbranchid = x.schoolbranchid,                               salarycomponentid = x.salarycomponentid,                               salarycomponentname = x.tbl_salarycomponent.salarycomponentname,                               staffname = x.tbl_staff.lastname + " " + x.tbl_staff.firstname,                               amount = x.amount,                               taxamount = x.tbl_staff.tbl_tax.count(y=>y.payrollid == payrollid && y.staffid == x.staffid) == 0 ? 0 : x.tbl_staff.tbl_tax.firstordefault(y=>y.payrollid == payrollid && y.staffid == x.staffid).amount,                               leaveamount = x.tbl_staff.tbl_paidleave.count(y => y.payrollid == payrollid && y.staffid == x.staffid) == 0 ? 0 : x.tbl_staff.tbl_paidleave.firstordefault(y => y.payrollid == payrollid && y.staffid == x.staffid).amount,                               loanamount = x.tbl_staff.tbl_paidloan.count(y => y.payrollid == payrollid && y.staffid == x.staffid) == 0 ? 0 : x.tbl_staff.tbl_paidloan.firstordefault(y => y.payrollid == payrollid && y.staffid == x.staffid).amount,                               staffid = x.staffid,                               payrollid = x.payrollid,                            };                return query;           } 

view template:

<table class="table table-striped table-hover">                             <thead>                                 <tr>                                      <th class="table-item-title table-item-w30">staff name</th>                                     <th class="table-item-title table-item-w20">component</th>                                     <th class="table-item-title table-item-w20">component amount</th>                                     <th class="table-item-title table-item-w10">tax</th>                                     <th class="table-item-title table-item-w10">loan</th>                                     <th class="table-item-title table-item-w10">leave</th>                                  </tr>                             </thead>                             <tbody>                                 <tr data-ng-repeat="item in payrollbyiditem">                                     <td>{{item.staffname}}</td>                                     <td>{{item.salarycomponentname}}</td>                                     <td>{{item.amount}}</td>                                     <td>{{item.taxamount}}</td>                                     <td>{{item.loanamount}}</td>                                     <td>{{item.leaveamount}}</td>                                 </tr>                              </tbody>                         </table> 


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -