Code: Select all
from th in db.transaction_header
join tl in db.transaction_line on th.transaction_id equals tl.transaction_id
join md1 in db.sv_merchandise_detail on new {th.transaction_id, tl.line_id} equals new {md1.transaction_id, md1.line_id} into md1
from md in md1.DefaultIfEmpty()
where th.transaction_id == transactionId && tl.line_void_flag == 0
group new {th, tl, md} by th.transaction_id
into g
select new ClassTransactionSummary
{
TransactionId = g.Key,
TotalGross = g.Where(w => w.tl.line_object_type.Equals(1)).Sum(s => (decimal?)s.tl.gross_line_amount) ?? 0,
TotalNet = g.Where(w => w.tl.line_object_type.Equals(2)).Sum(s => (decimal?)(s.tl.gross_line_amount - s.tl.pos_discount_amount) * s.tl.db_cr_none * -1 * s.tl.voiding_reversal_flag) ?? 0
}).FirstOrDefault();
In linq pad this work fine.
But in my project I got this error:
Exception:
Error on executing DbCommand.
Innermessage:
Invalid column name 'transaction_id1'.
Invalid column name 'line_id1'.
Invalid column name 'line_id'.
Invalid column name 'line_void_flag'.
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Ambiguous column name 'db_cr_none'.
Ambiguous column name 'voiding_reversal_flag'.
Ambiguous column name 'db_cr_none'.
Ambiguous column name 'voiding_reversal_flag'.
Any help?
Thanks