I
I
Ilya Magdenko2017-04-27 23:30:48
C++ / C#
Ilya Magdenko, 2017-04-27 23:30:48

How to show data in a table after a certain date?

This is the error that pops up for me.

An unhandled exception of type 'System.NotSupportedException' occurred
in EntityFramework.SqlServer.dll
Additional information: The specified type member 'Date' is not
supported in LINQ to Entities. Only initializers, entity members, and
entity navigation properties are supported
.
Here is the code
private void OnActive(object sender, RoutedEventArgs e)
            {
                DateTime TodayDate = DateTime.Now.Date; // init
    
                var query = from RentCarDB in this.dbContext.RentCarDBSet
                            where RentCarDB.StartDate.Date <= TodayDate
                            orderby RentCarDB.StartDate
                            select RentCarDB;
                this.rentCarDBViewSource.Source = query.ToList();
            }

How to show data that is after today's date?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Magdenko, 2017-04-27
@duntik

If anyone is interested, I added
And changed the line from
to

where DbFunctions.TruncateTime(RentCarDB.StartDate) <= TodayDate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question