i have a mapped-class like this:
[Table("MyTable")]
class MyClass
{
//properties; id, name, etc...
private string _queuedToWHTime = string.Empty;
[Column("QueuedToWHTime")]
public string QueuedToWHTime
{
get { return _queuedToWHTime; }
set { _queuedToWHTime = value; }
}
public DateTime? QueuedToWHTime_DateTime
{
get
{
if (!string.IsNullOrWhiteSpace(_queuedToWHTime))
{
return Convert.ToDateTime(_queuedToWHTime);
}
return null;
}
}
}
and a table (MyTable):
CREATE TABLE webnews_in
(
Id INT NOT NULL auto_increment,
QueuedToWHTime VARCHAR (50) NULL
...
PRIMARY KEY (Id)
);
when i trying to query like this:
var searchRslt=(from m in queryableNews
orderby m.QueuedToWHTime_DateTime descending
select m).ToList();
I got a NotSupportedException:The specified type member ‘QueuedToWHTime_DateTime’ is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
You cannot query with EF on custom properties. The custom property cannot be translated in SQL.
You can do this to force the orderby to be done ‘in-memory’.