I am new to Entity Framework and Linq in C#. In my code, I want to get data by comparing DateTimeOffset fromTime
which is coming from datepicker. and EvenDateUTC
is my database column name.
but its showing error: Specified cast is not valid.
please help what I am misssing.
my C# code is :-
if (fromTime.HasValue)
{
var tmp = new DateTimeOffset(fromTime.Value.ToUniversalTime());
query = query.Where(x => x.audit.EventDateUTC >= tmp);
}
in Sql query
( CAST( [Extent1].[EventDateUTC] AS datetimeoffset) >= @p__linq__0)
in sql: it showing error: Must declare the scalar variable "@p__linq__0".