Created
February 14, 2013 08:22
-
-
Save robashton/4951315 to your computer and use it in GitHub Desktop.
I'm quite pleased with this new feature
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 ordersForCustomer = session.Query<Order>() | |
.Where(order => order.CustomerId == "customers/bob") | |
.TransformWith<OrderWithProductInformation, OrderWithProductInformation.Result>() | |
.List(); |
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
public class OrderWithProductInformation : AbstractTransformerCreationTask<Order> | |
{ | |
public class Result | |
{ | |
public string OrderId { get; set; } | |
public string CustomerId { get; set; } | |
public ResultProduct[] Products { get; set; } | |
} | |
public class ResultProduct | |
{ | |
public string ProductId { get; set; } | |
public string ProductName { get; set; } | |
} | |
public OrderWithProductInformation() | |
{ | |
TransformResults = orders => from index in orders | |
let doc = LoadDocument<Order>(index.Id) | |
select new | |
{ | |
OrderId = doc.Id, | |
Products = from productid in doc.ProductIds | |
let product = LoadDocument<Product>(productid) | |
select new | |
{ | |
ProductId = product.Id, | |
ProductName = product.Name | |
} | |
}; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment