Created
July 25, 2017 16:37
-
-
Save filipececcon/77d0b4a3e3309ac77ba180671d67ef4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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