I\'m building a Web API project that will be made available to third-party\'s and also used by my own web application/s. The Web API methods will return JSON representations
In my query I have parent table with multiple childs.
public class TeamWithMembers
{
public int TeamId { get; set; }
public string TeamName { get; set; }
public string TeamDescription { get; set; }
public List TeamMembers { get; set; }
}
In this when I was using the ToList() in the linq query it is giving the error.
Now I am using the anonymous type in the linq query and convert it into the next query like this
List teamMemberList = teamMemberQueryResult.AsEnumerable().Select(item =>
new TeamModel.TeamWithMembers() {
TeamId=item.TeamId,
TeamName=item.TeamName,
TeamMembers=item.TeamMembers.ToList()
}).ToList();
Where teamMemberQueryResult is the resultset from the linq query.