ADO.NET EF does not support things like Math.Pow and Math.Log so I was wondering how I can get around this. I need to be able to use an ORDER BY on a calculated value using ADO.NET EF.
+2
A:
You can using Entity SQL, but I wouldn't recommend it
using System.Data.EntityClient;
EntityConnection conn = new EntityConnection(myContext.Connection.ConnectionString);
conn.Open();
EntityCommand cmd = conn.CreateCommand();
cmd.CommandText = @"Select SqlServer.Power(t.MyValue, 2) From MyEntities.MyTable As t";
var result = cmd.ExecuteReader(System.Data.CommandBehavior.SequentialAccess);
result.Read();
var valuePower2 = result.GetValue(0);
conn.Close();
To do dynamic order by's and where clauses use Dynamic Linq
TFD
2009-03-01 03:26:15