I have two table (mysql) with master-detail relationship that I want to query in Linq (and then experiment it in LinqPad). The problem is Linq to SQL can't produce the correct result nor SQL statement for the following query
from m in masters
select new {
m.Code,
m.Total,
Value = m.details.Sum(d => d.Qty * d.Price * (1 - 6/100))
}
and another one
from m in masters
select new {
m.Code,
m.Total,
Value = m.details.Sum(d => d.Qty * d.Price * 0.94)
}
the first query will not produce the correct result as the latter, the problem after I check in LinqPad lies within the (1 - 6/100)
that compiled into 1.0
. Can someone explain why?