T
Trebor
Hi,
I'm trying to convert a code from 'linq to sql' to 'linq to entities' and
I'm facing the problem when I'm trying to substract two datetime columns.
var q = from l in lh
where (l.LoginDate >= Date1)
select new
{
l.UserId,
l.LoginDate,
l.LogOutDate,
Minutes =
(DateTime?)System.DateTime.Today.Add((TimeSpan)( l.LogOutDate -
l.LoginDate )) // this line causes a runtime error in 'Linq to Entities'
};
The error message is: LINQ to Entities does not recognize the method
'System.DateTime Add(System.TimeSpan)' method,
and this method cannot be translated into
a store expression.
Any help will be appreciated.
I'm trying to convert a code from 'linq to sql' to 'linq to entities' and
I'm facing the problem when I'm trying to substract two datetime columns.
var q = from l in lh
where (l.LoginDate >= Date1)
select new
{
l.UserId,
l.LoginDate,
l.LogOutDate,
Minutes =
(DateTime?)System.DateTime.Today.Add((TimeSpan)( l.LogOutDate -
l.LoginDate )) // this line causes a runtime error in 'Linq to Entities'
};
The error message is: LINQ to Entities does not recognize the method
'System.DateTime Add(System.TimeSpan)' method,
and this method cannot be translated into
a store expression.
Any help will be appreciated.