I receiving the error since that i am trying to convert system.data.datable to entity collection. Please advise how i should implement it? thank you
public EntityCollection<ParticipationEntity> GetProgramInstanceParticipationByInstancesId(int programInstanceId)
{
EntityCollection<ParticipationEntity> pEC = new EntityCollection<ParticipationEntity>();
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.AddWithAnd(ParticipationFields.ProgramInstanceId == programInstanceId);
IPrefetchPath2 pfPath = new PrefetchPath2(EntityType.ParticipationEntity);
pfPath.Add(ParticipationEntity.PrefetchPathStudentEnrolment);
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(pEC, filter, pfPath);
}
EntityService es = new EntityService();
DataTable dt = new DataTable();
dt = es.CollectionToDataTable<ParticipationEntity>(pEC, "");
dt.Columns.Add("StudentName");
int i = 0;
foreach (DataRow r in dt.Rows)
{
r["StudentName"] = pEC.Items[i].StudentEnrolment.Surname + ", " + pEC.Items[i].StudentEnrolment.GivenName;
i++;
}
return dt;
}