0

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".

  • Sorry I can't help you. When I use the code provided I get a completely different error. There must be something else to reproduce? –  Oct 10 '18 at 12:06
  • https://stackoverflow.com/questions/7208709/entity-framework-4-1-unable-to-cast-from-dbquery-to-objectquery @Watcher i think its like this ^^ issue. but I did understand how to solve this –  Oct 10 '18 at 12:12

0 Answers0