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
/// <summary> | |
/// RavenDB Transformer that turns a Recipe into a RecipeViewModel. | |
/// </summary> | |
public class RecipeViewModelTransformer : AbstractTransformerCreationTask<Recipe> | |
{ | |
public RecipeViewModelTransformer() | |
{ | |
TransformResults = allRecipes => from recipe in allRecipes | |
let chef = LoadDocument<Chef>(recipe.ChefId) | |
let comments = LoadDocument<Comment>(recipe.CommentIds) | |
select new RecipeViewModel | |
{ | |
RecipeId = recipe.Id, | |
Name = recipe.Name, | |
PictureUrl = recipe.PictureUrl, | |
Ingredients = recipe.Ingredients, | |
Categories = recipe.Categories, | |
ChefEmail = chef.Email, | |
ChefName = chef.Name, | |
Comments = comments | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment