Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/58230eaaf27aa794c2c3062711e22416 to your computer and use it in GitHub Desktop.
Save ssougnez/58230eaaf27aa794c2c3062711e22416 to your computer and use it in GitHub Desktop.
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