Skip to content

Instantly share code, notes, and snippets.

@rofr
Created December 1, 2017 10:51
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 rofr/5a7d1cd3b69954b9690ecb3eab326293 to your computer and use it in GitHub Desktop.
Save rofr/5a7d1cd3b69954b9690ecb3eab326293 to your computer and use it in GitHub Desktop.
Memstate models are strongly typed object graphs
//user defined model with collections of user defined entities
class MyGraph {
Dictionary<Guid,Customer> Customers;
Dictionary<Guid,Order> Orders;
Dictionary<Guid,Product> Products;
}
class Order {
Customer Customer;
List<OrderLine> Lines;
}
class OrderLine {
Product Product;
Quantity Quantity;
}
//Customers who purchased an Echo
var customerNames = graph.Orders.Values
.Where(order => order.Lines.Any(line => line.Product.Name == "Echo"))
.Select(order => order.Customer.CompanyName)
.Distinct();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment