none
using ABS(Amount) in a Linq to SQL expression? RRS feed

  • Question

  • I have a Linq to SQL statement that looks like this...

                var q = from x in db.Transactios
                        where x.Amount > 100
                        orderby x.Date descending, x.Id
                        select x;

    I really need the comparison to be againts ABS(Amount) and not just Amount in the emitted SQL.

    Is there some slick Linq to SQL thing I have missed that allows me to do that?

    Thanks !
    Thursday, August 28, 2008 1:25 PM

Answers

  • Most of the Math.XXX methods are translated into SQL.

     

     var q = from x in db.Transactios
                        where Math.Abs(x.Amount) > 100
                        orderby x.Date descending, x.Id
                        select x;

     

    Thursday, August 28, 2008 3:53 PM
    Moderator

All replies

  • Most of the Math.XXX methods are translated into SQL.

     

     var q = from x in db.Transactios
                        where Math.Abs(x.Amount) > 100
                        orderby x.Date descending, x.Id
                        select x;

     

    Thursday, August 28, 2008 3:53 PM
    Moderator
  • simply great!
    Thursday, August 28, 2008 10:23 PM