EF 4: The specified type member '*' is not supported in LINQ to Entities

前端 未结 2 591
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 08:58

i have a mapped-class like this:

[Table(\"MyTable\")]
class MyClass         
{   
        //properties; id, name, etc...

        private string _queuedToWHTime          


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 09:53

    The issue is here:

    var searchRslt=(from m in queryableNews
    orderby m.QueuedToWHTime_DateTime descending
    select m).ToList();
    

    you are trying to use the property .QueuedToWHTime_DateTime, but that does not exist in the database. You need to use the names that are used in the database. In this case .QueuedToWHTime So:

    var searchRslt=(from m in queryableNews
    orderby m.QueuedToWHTime descending
    select m).ToList();
    

    If the database propery is not usable in this scenario, you will have to pull the entire list, convert it to an IEnumerable (any will do), then filter/order that IEnumerable by its property.

    Something like this:

    var result = queryableNews.ToList().OrderbyDescending(x=>x.QueuedToWHTime_DateTime).ToList();
    

提交回复
热议问题