Problem with using Math.Abs

Posts   
 
    
jbliss1234
User
Posts: 42
Joined: 04-May-2007
# Posted on: 26-Oct-2010 00:38:26   

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.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Oct-2010 06:34:11   

Math.Abs isn't mapped. You have to create your own Custom Function Mapping.

David Elizondo | LLBLGen Support Team