Skip to content

Instantly share code, notes, and snippets.

@filipececcon
Created July 25, 2017 16:37
Show Gist options
  • Save filipececcon/77d0b4a3e3309ac77ba180671d67ef4f to your computer and use it in GitHub Desktop.
Save filipececcon/77d0b4a3e3309ac77ba180671d67ef4f to your computer and use it in GitHub Desktop.
public override IEnumerable<Player> GetAll()
{
const string sql = "SELECT J.*, T.NM_TIME FROM TB_JOGADOR AS J INNER JOIN TB_TIME AS T ON J.ID_TIME = T.ID";
using (var db = new SqlConnection(ConnectionString))
{
var result = db.Query(sql);
return result.Select(player => new Player
{
Id = player.ID,
Name = player.NM_JOGADOR,
Age = player.NR_IDADE,
Team = new Team
{
Id = player.ID_TIME,
Name = player.NM_TIME
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment