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:
view b:
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
Post a Comment