public List <PlayerDetailsEL> GetPlayerDetailsByRoleId(int matchId, int roleId) { try { PlayerDetailsEL objPDEL; List <PlayerDetailsEL> lstPD = new List <PlayerDetailsEL>(); var playerdetails = objPlayerDB.GetPlayerDetails(matchId); playerdetails = (from res in playerdetails where res.PlayerRoleId == roleId select res).ToList(); foreach (var a in playerdetails) { objPDEL = new PlayerDetailsEL(); objPDEL.PlayerId = a.PlayerId; objPDEL.PlayerName = a.PlayerName; objPDEL.PlayerRoleId = a.PlayerRoleId; objPDEL.PlayerTeamId = a.TeamId; objPDEL.TeamName = objPlayerDB.GetTeamNameById((int)a.TeamId); objPDEL.PlayerPoints = a.Points; lstPD.Add(objPDEL); } lstPD = lstPD.OrderByDescending(t => t.PlayerPoints).ToList(); return(lstPD); } catch (Exception ex) { throw ex; } }