how can i write the orcle query in linq [Resolved]

Posted by Kasani007 under LINQ on 4/28/2016 | Points: 10 | Views : 427 | Status : [Member] | Replies : 1
select a.* , (SELECT count(*)
FROM branch_expense_lines bl,
branch_expense be,
payment_indents pi,
payment_ind_branch_expenses pie,
payment_vhr_branch_expenses pve ,
payment_vouchers pv
WHERE be.BRANCH_EXPENSE_ID =bl.BRANCH_EXPENSE_ID
and pv.PAYMENT_VOUCHER_ID=pve.PAYMENT_VOUCHER_ID
AND bl.ACCOUNT_ID =pie.account_id
AND be.branch_id =pi.branch_id
AND pi.payment_indent_id =pie.payment_indent_id
AND pie.IND_BRANCH_EXPENSE_ID=pve.IND_BRANCH_EXPENSE_ID
and pv.PAYMENT_RECEIPT_DATE between trunc(to_date('01-04-2016','dd-mm-yyyy')) and bl.EXPENSE_DATE and bl.branch_expense_id=a.branch_expense_id) cnt
from branch_expense_lines a;

please help me...




Responses

Posted by: Professionaluser on: 4/28/2016 [Member] [MVP] Bronze | Points: 50

Up
-1
Down

Resolved
check the below query and let me know if you get any error message
from a in branch_expense_lines

select new {
col1 = a.col1,
col2 = a.col2,
Cnt = (from bl in branch_expense_lines
join be in branch_expense on (bl.BRANCH_EXPENSE_ID equals be.BRANCH_EXPENSE_ID and bl.branch_expense_id equals a.branch_expense_id)
join pi in payment_indents on be.branch_id equals pi.branch_id
join pie in payment_ind_branch_expenses on (pi.payment_indent_id equals pie.payment_indent_id and bl.ACCOUNT_ID equals pie.account_id)
join pve in payment_vhr_branch_expenses on pie.IND_BRANCH_EXPENSE_ID equals pve.IND_BRANCH_EXPENSE_ID
join pv in payment_vouchers on pve.PAYMENT_VOUCHER_ID equals pv.PAYMENT_VOUCHER_ID
and (pv.PAYMENT_RECEIPT_DATE >= DateTime.Parse("01-04-2016") and pv.PAYMENT_RECEIPT_DATE <= bl.EXPENSE_DATE)
).Count()
}

i haven't tested above query, just converted SQL to LINQ code... :)

refer
http://stackoverflow.com/questions/7175081/linq-to-enitities-count-subquery
http://stackoverflow.com/questions/2453823/linq-to-sql-how-to-perform-a-count-on-a-sub-select

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response