Created
July 14, 2018 15:52
-
-
Save ssougnez/58230eaaf27aa794c2c3062711e22416 to your computer and use it in GitHub Desktop.
This file contains 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
var sql = new Sql() | |
.Select("*") | |
.From<Movie>(dbContext.SqlSyntax) | |
.Where<Movie>(m => m.Title == "Avatar", dbContext.SqlSyntax); | |
var avatar = dbContext.Database.Fetch<Movie>(sql).FirstOrDefault(); | |
sql = new Sql() | |
.Select("Actors.*") | |
.From<Actor>(dbContext.SqlSyntax) | |
.InnerJoin<ActorMovie>(dbContext.SqlSyntax) | |
.On<ActorMovie, Actor>(dbContext.SqlSyntax, am => am.ActorId, ac => ac.Id) | |
.Where<ActorMovie>(am => am.MovieId == a.Id, dbContext.SqlSyntax); | |
avatar.Actors = dbContext.Database.Fetch<Actor>(sql); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment