Im creating a webgrid. one of my column is of collection complex type:
[Table("RequestStatus",Schema="dbo")]
public class RequestStatus
{
[Key]
public int Id { get; set; }
public string Status { get; set; }
}
and in my entity:
public virtual ICollection<RequestStatus> RequestStatuses { get; set; }
in my webgrid i want to be able to sort by this property in a way similar to this:
RequestStatuses.Last().Status
I created a readonly property in my entity:
[NotMapped]
public string LastRequestStatus
{
get { return this.RequestStatuses.Last().Status; }
}
but i get:
System.NotSupportedException: The specified type member 'LastRequestStatus' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supporte
I assume that is becasue this property is not mapped to db field. is there a way to handle this situation out of the box or i need to write custom sorting for that?
Thanks in advance!