I'm using this model:
public partial class users_logged
{
public string UserName { get; set; }
public System.DateTime Date { get; set; }
public Nullable<double> TimeSpent { get; set; }
}
And I'm trying to get the data of the users logged yesterday with this Linq query:
var innerJoinQuery = (from t in context.users_logged
where t.Date.Date == DateTime.Now.Date.AddDays(-1)
select new
{
UserName = t.UserName,
Date = t.Date,
TimeSpent = t.TimeSpent
}).ToList();
(users_logged.Date or t.Date is a datetime field, I just want to get the day from this)
But when I'm running it, I get this exception:
[NotSupportedException: The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.]
I understand the error but I'm not able to solve it. I tried to use DbFunctions.TruncateTime
but my MySQL DB doesn't support it. Any tips?