I have a table with a column called AmountToBeTraded, which is modeled in SQL Server as a float.
In my table, there are values stored in this column that are negative. I am trying to compute a sum of absolute values of this column, however, my query is not returning absolute values.
The query is:
public double TotalAmount
{
get
{
LinqMetaData metaData = new LinqMetaData();
var retVal = (from c in metaData.FeeRecord
where c.FeeId == this.Id
&& c.AmountToBeTraded != 0.0
select Math.Abs(c.AmountToBeTraded)).Sum();
return retVal;
}
}
When I profiled in SQL Server, the query generated is:
exec sp_executesql N'SELECT TOP(@top0) SUM([LPA_L1].[AmountToBeTraded]) AS [LPAV_] FROM (SELECT [LPLA_1].[AmountToBeTraded] FROM [SecureLogin].[dbo].[FeeRecord] [LPLA_1] WHERE ( ( ( ( [LPLA_1].[FeeId] = @FeeId2) AND ( [LPLA_1].[AmountToBeTraded] <> @AmountToBeTraded3))))) [LPA_L1]',N'@top0 bigint,@FeeId2 int,@AmountToBeTraded3 float',@top0=1,@FeeId2=27,@AmountToBeTraded3=0
Looks like the Math.Abs operator is completely ignored. Please help.
I am using the Oct 9, 2010 version of LLBLGen.