WAQS Querying: Math methods

7 reasons to use WAQS

WAQS documentation

 

Math calculation with LINQ To Entities

As with DateTime calculation, Math methods such as Abs, Ceiling, Floor, Pow, Round and Truncate are not supported by LINQ To Entities. With L2E queries, you have to use EntityFunctions methods which is not great.

 

With LINQ To WAQS and LINQ To Entities + WAQS, these methods are supported.

L2WAQS ex:

await _context.Orders.AsAsyncQueryable().Select(o => Math.Round(o.Total, 2)).ExecuteAsync();


 



L2EW ex:



_context.Orders.Select(o => Math.Round(o.Total, 2))






So you can write some queries using Math methods with no reference on Entity Framework.



 



Note that Round method is a little bit more complex than others. More details here.

This entry was posted in 12253, 16868, 7671. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>