Here's my code:
public List
{
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
}
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:
|
Thank You.

Akkiraju IvaturiPosted Sep 16, 2012, 10:57 PM