Basically I have a QueryExtender control of ASP.NET and First I need to Convert sql varchar value to TimeSpan of CSharp type then apply Linq OrderBy Clause on it, but get an error when execute.
Here is my code:
protected void FilterProducts(object sender, CustomExpressionEventArgs e)
{
e.Query = (from p in e.Query.Cast<accounts>()
select p).OrderBy(p=> TimeSpan.Parse(p.TimeTo));
}
ERROR: LINQ to Entities does not recognize the method 'System.TimeSpan Parse(System.String)' method, and this method cannot be translated into a store expression.