Hi mindcrackers,
Here's my code:
public List<DAL.Assessment> search_by_id(Int64 id)
{
DAL.PVA_DBMSEntities objEntity = new DAL.PVA_DBMSEntities();
var getdata = (from sub in objEntity.Subjects
from skul in objEntity.Schools
from leaner in objEntity.Learners
from ass in objEntity.Assessments
where (ass.Learner_Id == leaner.Learner_Id)
&& (ass.Learner_Id == id) && (ass.Subject_Id == sub.Subject__Id)
select new
{
leaner.Learner_Id,
sub.Description,
ass.Assessment_type,
ass.Mark,
});
return (List<DAL.Assessment>)getdata;
}
Server Error in '/' Application.
Unable to cast object of type 'System.Data.Objects.ObjectQuery`1[<>f__AnonymousType3`4[System.Int32,System.String,System.String,System.Decimal]]' to type 'System.Collections.Generic.List`1[PVA.DAL.Assessment]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Data.Objects.ObjectQuery`1[<>f__AnonymousType3`4[System.Int32,System.String,System.String,System.Decimal]]' to type 'System.Collections.Generic.List`1[PVA.DAL.Assessment]'.
Source Error:
Line 93: }); Line 94: Line 95: return (List<DAL.Assessment>)getdata; Line 96: }
|
Thank You.