I have DB table Vehicle and I am using EF4. So I got a partial class Vehicle to map with the db table.
Vehicle is a master table. It has a detail table Fault. 1 vehicle could have many faults.
I am trying to get the count of fault associated with vehicle. So I created one customized property for Vehicle class. FaultCount.
Everything works fine. I got the data I want and populate the grid. But when I try to sort the column, I get the exception.
"The specified type member 'FaultCount' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."
Any help?
Thx,
David
Vehicle is a master table. It has a detail table Fault. 1 vehicle could have many faults.
I am trying to get the count of fault associated with vehicle. So I created one customized property for Vehicle class. FaultCount.
Partial Class Vehicle
{
public global::System.Int32 FaultCount
{
get
{
CCF20Entities ccf20Ent = new CCF20Entities();
return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "Vehcile" && f.VehicleID== this.VehicleID).Count();
}
}
}Everything works fine. I got the data I want and populate the grid. But when I try to sort the column, I get the exception.
"The specified type member 'FaultCount' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."
Any help?
Thx,
David