Is there a function similar to Math.Max for Entity Framework?
Posted
by Ryan ONeill
on Stack Overflow
See other posts from Stack Overflow
or by Ryan ONeill
Published on 2010-04-15T10:34:22Z
Indexed on
2010/04/15
13:03 UTC
Read the original article
Hit count: 232
entity-framework
I have an entity framework query as follows;
From T In Db.MyTable
Where (T.Col1 - T.Col2) + T.Col3 - T.Col4 > 0 _
Select T
I now need to make sure that the bracketed part '(T.Col1 - T.Col2)' does not go below zero.
In .Net, I'd code it as follows (but obviously EF does not like Math.Max).
From T In Db.MyTable
Where Math.Max(T.Col1 - T.Col2,0) + T.Col3 - T.Col4 > 0 _
Select T
Is there an easy way to do this? I am using EF 2.0 (not the latest, just released version).
Thanks in advance
© Stack Overflow or respective owner