Created
December 1, 2017 10:51
-
-
Save rofr/5a7d1cd3b69954b9690ecb3eab326293 to your computer and use it in GitHub Desktop.
Memstate models are strongly typed object graphs
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
//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