public static void CustomerManagerWithProperties() { var cust = new Customer2(1, "Amelio Rosales"); //cust.ID = 2; // Error Property or indexer cannot be assigned to -- it is read only Console.WriteLine("ID: {0}, Name: {1}", cust.ID, cust.Name); }
private Customer2 CreateCustomer2() { var customer = new Customer2(); customer = CreateBaseInfo(customer) as Customer2; return(customer); }
private void givenEmailAddressWasChanged() { var command = ChangeCustomerEmailAddress.Build(customerID.Value, changedEmailAddress.Value); changedConfirmationHash = command.ConfirmationHash; registeredCustomer = Customer2.ChangeEmailAddress(registeredCustomer, command); }
public async Task <IActionResult> Index() { var url = _configuration.GetValue("TestApi1Url", "http://testapi1:60001"); IEnumerable <Customer> customers = new [] { new Customer() { Id = 20001, Name = "David", Location = Environment.MachineName } }; try { var customerClient = RestService.For <ICustomerApi>(url); customers = await customerClient.GetCustomersAsync(); } catch (Exception e) { Console.WriteLine(e); } Customer2 customer2 = new Customer2() { Customers = customers, ApiServerUrl = url, HostingEnvironment = _hostingEnvironment.EnvironmentName }; return(View(customer2)); }
/** * Helper methods to set up the Given state */ private void givenARegisteredCustomer() { var register = RegisterCustomer.Build(emailAddress.Value, name.GivenName, name.FamilyName); customerID = register.CustomerId; confirmationHash = register.ConfirmationHash; registeredCustomer = Customer2.Register(register); }
static void Main(string[] args) { Customer1 c1 = new Customer1(); DoSomething(c1); Customer2 c2 = new Customer2(); DoSomething(c2); }
private void givenEmailAddressWasConfirmed() { var command = ConfirmCustomerEmailAddress.Build(customerID.Value, confirmationHash.Value); try { registeredCustomer = Customer2.ConfirmEmailAddress(registeredCustomer, command); } catch (WrongConfirmationHashException e) { throw new XunitException("unexpected error in givenEmailAddressWasConfirmed: " + e.Message); } }
public void x() { var e = new MyEntityBase(); // var e2 = new Customer(); var e3 = new Customer2(); var x = e.Extensions; //var x2 = e2.Extensions; //var x3 = e3.Extensions; }
void confirmEmailAddress_withWrongConfirmationHash() { // Given givenARegisteredCustomer(); // When confirmCustomerEmailAddress // Then it should throw WrongConfirmationHashException var command = ConfirmCustomerEmailAddress.Build(customerID.Value, wrongConfirmationHash.Value); Assert.Throws <WrongConfirmationHashException>(() => Customer2.ConfirmEmailAddress(registeredCustomer, command)); }
public static void Main(string[] args) { customer obj = new customer("Barack", "Obama"); obj.AppendData(); Customer2.getdata(); Customer3 obj1 = new Customer3(); obj1.getData(); Name obj2 = new Name(); obj2.setName("Sharma"); obj2.setName("Aditya", "Sharma"); obj2.setName("Aditya", "N", "Sharma"); Rectangle obj3 = new Rectangle(); obj3.getdata2(); obj3.Display(); Father fObj = new Father(); fObj.FatherMethod(); //Here Child object can access both class methods Child cObj = new Child(); cObj.FatherMethod(); cObj.ChildMethod(); IStudent obj5 = new StudentDetails(); obj5.print(); //IStudent a = new IStudent(); StudentDetails std = new StudentDetails(); std.print(); std.marks(); Console.ReadKey(); DClass d = new DClass(); d.GetInfo(); BClass b = new BClass(); b.GetInfo(); }
public void CreateObjectNonAbstract() { Customer2 customer = Customer2.New(); customer.Name = "BLABLA1"; customer.Save(); Assert.IsTrue(customer.CustomerID > 0); Customer2 customer2 = Customer2.Read(customer.CustomerID); Assert.AreEqual(customer.Name, customer2.Name); }
void confirmEmailAddress() { // Given givenARegisteredCustomer(); // When confirmCustomerEmailAddress // Then it should succeed var command = ConfirmCustomerEmailAddress.Build(customerID.Value, confirmationHash.Value); var changedCustomer = Customer2.ConfirmEmailAddress(registeredCustomer, command); // and the emailAddress of the changed Customer should be confirmed Assert.True(changedCustomer.IsEmailAddressConfirmed); }
public void EntityNamesCanBeOverridden() { //Arrange var item = new Customer2(); //Act var result = TargetAnalyser.Analyse(item); //Assert var output = new Output(); output.FormatTable(result.Fields.Select(f => new { f.Entity, Field = f.Field.Describe(), Type = f.Type.Name })); output.Report.Verify(); }
void changeEmailAddress() { // Given givenARegisteredCustomer(); // When changeCustomerEmailAddress var command = ChangeCustomerEmailAddress.Build(customerID.Value, changedEmailAddress.Value); var changedCustomer = Customer2.ChangeEmailAddress(registeredCustomer, command); // Then the emailAddress and confirmationHash should be changed and the emailAddress should be unconfirmed Assert.Equal(command.EmailAddress, changedCustomer.EmailAddress); Assert.Equal(command.ConfirmationHash, changedCustomer.ConfirmationHash); Assert.False(changedCustomer.IsEmailAddressConfirmed); }
void registerCustomer() { // When var command = RegisterCustomer.Build(emailAddress.Value, name.GivenName, name.FamilyName); var customer = Customer2.Register(command); // Then it should succeed // and it should expose the expected state Assert.NotNull(customer); Assert.Equal(command.CustomerId, customer.CustomerId); Assert.Equal(command.Name, customer.Name); Assert.Equal(command.EmailAddress, customer.EmailAddress); Assert.Equal(command.ConfirmationHash, customer.ConfirmationHash); Assert.False(customer.IsEmailAddressConfirmed); }
void confirmEmailAddress_whenItWasPreviouslyConfirmedAndThenChanged() { // Given givenARegisteredCustomer(); givenEmailAddressWasConfirmed(); givenEmailAddressWasChanged(); // When confirmEmailAddress // Then it should throw WrongConfirmationHashException var command = ConfirmCustomerEmailAddress.Build(customerID.Value, changedConfirmationHash.Value); var changedCustomer = Customer2.ConfirmEmailAddress(registeredCustomer, command); // and the emailAddress of the changed Customer should be confirmed Assert.True(changedCustomer.IsEmailAddressConfirmed); }
public async Task <IActionResult> Post([FromBody] CreateCustomerRequest request) { var validator = new CreateCustomerValidator(); var result = validator.Validate(request); if (!result.IsValid) { return(BadRequest(result.Errors)); } var address = Address2.Create(request.Address.HouseNoOrName, request.Address.Street, request.Address.City, request.Address.County, request.Address.PostCode ); var customer = Customer2.Create(request.CustomerId, request.FirstName, request.LastName, request.MiddleName, request.Title, address, request.DateOfBirth, request.CountryOfBirth, request.IdDocumentType, request.IdDocumentNumber, request.VatNumber, request.VatCountry); // wrap customer domain model var createCustomerCommand = new CreateCustomerCommand2(customer); // command handler returns response that wraps domain model var response = await _mediator.Send(createCustomerCommand); if (response.Status == OperationStatus.ValidationFailure) { return(BadRequest(response.ErrorMessages)); } if (response.Status == OperationStatus.Conflict) { return(Conflict(response)); } return(Ok(response.Value)); }
static void Main(string[] args) { // Arduino Mega 2560 defaults to COM4 on my PC // serial port sample code: http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.datareceived(v=vs.110).aspx try { // get the weather forecast and send what to wear suggestion to customer wunderground.GetWeather(); Customer customer1 = new Customer("sean", "cogley", 98021); Customer2 customer2 = new Customer2(); } catch (Exception e) { Console.WriteLine(e.ToString()); //TODO: SOME ERROR HANDLING HERE } }
public static ICustomer GetCustomerType(int customerTypeId) { ICustomer customer; if (customerTypeId == 1) { customer = new Customer1(); } else if (customerTypeId == 2) { customer = new Customer2(); } else { return(null); } return(customer); }
private static void UsingAPropertyExample() { Customer2 c = new Customer2(); /* Adding validation to the Name property does not change how the property is used in a program. * The code here sets the name of customer c to Rob... */ c.Name = "Rob"; Console.WriteLine("Customer name: {0}", c.Name); try { /* ... and then tries to set the name to an empty string, which causes an exception to be * thrown. */ c.Name = ""; //this statement will throw an exception } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public Customer2 GetCustomerInfo(string name) { var info = new Customer2(); using ( SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["RentalConnection"].ConnectionString)) { try { if (connection.State == ConnectionState.Closed) { connection.Open(); string query = "select * from Customer where Full_Name='" + name + "'"; var command = new SqlCommand(query, connection) { CommandType = CommandType.Text }; var reader = command.ExecuteReader(); while (reader.Read()) { info.Id = reader.GetInt32(0); info.FullName = reader.GetString(1); info.Phone = reader.GetString(2); info.Address = reader.GetString(3); info.Email = reader.GetString(4); //comp.Add(info); } reader.Close(); connection.Close(); } } catch (Exception exception) { MessageBox.Show(exception.Message.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } return(info); }
public ActionResult EntitySQL(int id = 0) { string esqlQuery = @"SELECT VALUE customers FROM AdventureWorksEntities.Customers AS customers WHERE customers.CustomerID == @id"; var customers = new List <Customer2>(); using (var conn = new EntityConnection("name=AdventureWorksEntities")) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = esqlQuery; var param = new EntityParameter { ParameterName = "id", Value = id }; cmd.Parameters.Add(param); using (var reader = cmd.ExecuteReader(System.Data.CommandBehavior.SequentialAccess)) { while (reader.Read()) { var customer = new Customer2 { CustomerID = int.Parse(reader["CustomerID"].ToString()), CustomerName = reader["FirstName"] + " " + reader["MiddleName"] + " " + reader["LastName"] }; customers.Add(customer); } } } conn.Close(); } return(View(customers)); }
static void Main() { ClassA interfaceClass = new ClassA(); interfaceClass.MyNumber = 10; interfaceClass.InterfaceMethod(); Customer c1 = new Customer(); Customer2 c2 = new Customer2(); c1.Print(); c2.Print(); //AbstractImplementation ab = new AbstractImplementation(); AbstractImplementation.NonAbstractClass nab = new AbstractImplementation.NonAbstractClass(); nab.PrintMessage(); nab.PrintMessageAbstract(); MemberPoly[] gymMembers = new MemberPoly[5]; gymMembers[0] = new RegularMemberPoly("Good member", "Tochukwu", 03, 2017); gymMembers[1] = new RegularMemberPoly("Good member", "Stanley", 04, 2019); gymMembers[2] = new VIPMemberPoly("Chijioke", 01, 2010); gymMembers[3] = new VIPMemberPoly("Marvellous", 02, 2017); gymMembers[4] = new VIPMemberPoly("Idam", 05, 2020); foreach (MemberPoly m in gymMembers) { m.CalculateAnnualFee(); Console.WriteLine(m.ToString()); if (m.GetType() == typeof(VIPMemberPoly)) { Console.WriteLine("yes, VIP"); } else { Console.WriteLine("no, not VIP"); } } MemberInheritanceDemo gymUser = new MemberInheritanceDemo(); RegularMember gymer = new RegularMember("very good", "Chijioke", 40, 50); VipMember vipGymer = new VipMember(); gymer.CalculateAnnualFee(); Console.WriteLine(gymer.ToString()); int v = 2; int[] r = { 1, 2, 3, }; ValueAndReference valRef = new ValueAndReference(); Console.WriteLine("v before = {0}", v); valRef.PassByValue(v); Console.WriteLine("v before = {0}", v); Console.WriteLine("\n\n"); Console.WriteLine("r[0] before = {0}", r[0]); valRef.PassByReference(r); Console.WriteLine("r[0] after = {0}", r[0]); ArraysLists arr = new ArraysLists(); arr.PrintFirstElement(arr.TheArray); arr.PrintFirstElement(arr.TheList); int[] myNewArray = arr.ReturnUserInput(); Console.WriteLine(myNewArray); var myNewList = arr.ReturnUserInputList(); //Console.WriteLine(myNewList); foreach (var item in myNewList) { Console.Write(item + ", "); } arr.PrintNames("Chijioke", "Gloria", "Wisest"); // Access non static members from StaticClass external class StaticClass nonStaticMembers = new StaticClass(); Console.WriteLine(nonStaticMembers.message); nonStaticMembers.Name = "Chijioke"; nonStaticMembers.DisplayName(); // Access static members from StaticClass external class StaticClass.Age = 33; Console.WriteLine(StaticClass.greetings); StaticClass.DisplayAge(); int pay; Staff staff1 = new Staff("Peter"); staff1.HoursWorked = 160; pay = staff1.CalculatePay(1000, 400); Console.WriteLine("Pay = {0}", pay); Staff staff2 = new Staff("Jane", "Lee"); staff2.HoursWorked = 100; staff2.StaffAge = 33; pay = staff2.CalculatePay(); Console.WriteLine("Pay = {0} and Age = {1}", pay, staff2.StaffAge); Staff staff3 = new Staff("Carol"); staff3.StaffAge = 26; staff3.HoursWorked = -10; pay = staff3.CalculatePay(); Console.WriteLine("{0} is {1} years old, his pay = {2}", staff3, staff3.StaffAge, pay); Console.WriteLine("{0}", staff3); }
public void Execute() { var customer = new Customer { Name = "CustomerName", DateTimeRegistration = DateTime.Now, Id = 1 }; var customer2 = new Customer2 { Name = "CustomerName2", DateTimeRegistration = DateTime.Now, Id = 2 }; IEnumerable <Order> orders = new List <Order> { new Order { Id = 1, Name = "Order1", DateTimeOrdered = DateTime.Now }, new Order { Id = 2, Name = "Order2", DateTimeOrdered = DateTime.Now }, new Order { Id = 3, Name = "Order3", DateTimeOrdered = DateTime.Now } }; customer.Orders.AddRange(orders); customer2.Orders.AddRange(orders); var json = SerializeJson(customer); var customerJson = DeserializeJson(json); Console.WriteLine($"Customer from json: {customerJson}"); var json2 = SerializeJsonAndWriteToFile(customer2); var customerJson2 = DeserializeJson(json2); Console.WriteLine($"Customer from json2: {customerJson2}"); SerializeXml(customer); var customerXml = DeserializeXml(customer); Console.WriteLine($"Customer from xml: {customerXml}"); SerializeBinary(customer); var customerBinary = DeserializeBinary(); Console.WriteLine($"Customer from binary: {customerBinary}"); }
public CreateCustomerCommand2(Customer2 customer) { Customer = customer; }
public void Includes() { using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_1_0 Order order = session .Include <Order>(x => x.CustomerId) .Load("orders/1234"); // this will not require querying the server! Customer customer = session .Load <Customer>(order.CustomerId); #endregion } } using (var store = new DocumentStore()) { #region includes_1_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234" }, includes: new[] { "CustomerId" }); RavenJObject order = result.Results[0]; RavenJObject customer = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_2_0 Order[] orders = session .Include <Order>(x => x.CustomerId) .Load("orders/1234", "orders/4321"); foreach (Order order in orders) { // this will not require querying the server! Customer customer = session.Load <Customer>(order.CustomerId); } #endregion } } using (var store = new DocumentStore()) { #region includes_2_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234", "orders/4321" }, includes: new[] { "CustomerId" }); List <RavenJObject> orders = result.Results; List <RavenJObject> customers = result.Includes; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_3_0 IList <Order> orders = session .Query <Order, Orders_ByTotalPrice>() .Customize(x => x.Include <Order>(o => o.CustomerId)) .Where(x => x.TotalPrice > 100) .ToList(); foreach (Order order in orders) { // this will not require querying the server! Customer customer = session .Load <Customer>(order.CustomerId); } #endregion } using (var session = store.OpenSession()) { #region includes_3_1 IList <Order> orders = session .Advanced .DocumentQuery <Order, Orders_ByTotalPrice>() .Include(x => x.CustomerId) .WhereGreaterThan(x => x.TotalPrice, 100) .ToList(); foreach (Order order in orders) { // this will not require querying the server! Customer customer = session .Load <Customer>(order.CustomerId); } #endregion } } using (var store = new DocumentStore()) { #region includes_3_2 QueryResult result = store .DatabaseCommands .Query( "Orders/ByTotalPrice", new IndexQuery { Query = "TotalPrice_Range:{Ix100 TO NULL}" }, includes: new[] { "CustomerId" }); List <RavenJObject> orders = result.Results; List <RavenJObject> customers = result.Includes; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_4_0 Order order = session .Include <Order>(x => x.SupplierIds) .Load("orders/1234"); foreach (Guid supplierId in order.SupplierIds) { // this will not require querying the server! Supplier supplier = session.Load <Supplier>(supplierId); } #endregion } } using (var store = new DocumentStore()) { #region includes_4_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234" }, includes: new[] { "SupplierIds" }); RavenJObject order = result.Results[0]; RavenJObject customer = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_5_0 Order[] orders = session .Include <Order>(x => x.SupplierIds) .Load("orders/1234", "orders/4321"); foreach (Order order in orders) { foreach (Guid supplierId in order.SupplierIds) { // this will not require querying the server! Supplier supplier = session.Load <Supplier>(supplierId); } } #endregion } } using (var store = new DocumentStore()) { #region includes_5_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234", "orders/4321" }, includes: new[] { "SupplierIds" }); List <RavenJObject> orders = result.Results; List <RavenJObject> customers = result.Includes; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_6_0 Order order = session .Include <Order>(x => x.Referral.CustomerId) .Load("orders/1234"); // this will not require querying the server! Customer customer = session.Load <Customer>(order.Referral.CustomerId); #endregion } using (var session = store.OpenSession()) { #region includes_6_2 Order order = session.Include("Referral.CustomerId") .Load <Order>("orders/1234"); // this will not require querying the server! Customer customer = session.Load <Customer>(order.Referral.CustomerId); #endregion } } using (var store = new DocumentStore()) { #region includes_6_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234" }, includes: new[] { "Referral.CustomerId" }); RavenJObject order = result.Results[0]; RavenJObject customer = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_7_0 Order order = session .Include <Order>(x => x.LineItems.Select(li => li.ProductId)) .Load("orders/1234"); foreach (LineItem lineItem in order.LineItems) { // this will not require querying the server! Product product = session.Load <Product>(lineItem.ProductId); } #endregion } } using (var store = new DocumentStore()) { #region includes_7_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234" }, includes: new[] { "LineItems.,ProductId" }); RavenJObject order = result.Results[0]; RavenJObject product = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_8_0 Order2 order = session .Include <Order2, Customer2>(x => x.CustomerId) .Load("order2s/1234"); // this will not require querying the server! Customer2 customer = session.Load <Customer2>(order.CustomerId); #endregion } } using (var store = new DocumentStore()) { #region includes_8_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "order2s/1234" }, includes: new[] { "CustomerId" }); RavenJObject order = result.Results[0]; RavenJObject customer = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_8_2 IList <Order2> orders = session .Query <Order2, Order2s_ByTotalPrice>() .Customize(x => x.Include <Order2, Customer2>(o => o.CustomerId)) .Where(x => x.TotalPrice > 100) .ToList(); foreach (Order2 order in orders) { // this will not require querying the server! Customer2 customer = session.Load <Customer2>(order.CustomerId); } #endregion } using (var session = store.OpenSession()) { #region includes_8_3 IList <Order2> orders = session .Advanced .DocumentQuery <Order2, Order2s_ByTotalPrice>() .Include("CustomerId") .WhereGreaterThan(x => x.TotalPrice, 100) .ToList(); foreach (Order2 order in orders) { // this will not require querying the server! Customer2 customer = session.Load <Customer2>(order.CustomerId); } #endregion } } using (var store = new DocumentStore()) { #region includes_8_4 QueryResult result = store .DatabaseCommands .Query( "Order2s/ByTotalPrice", new IndexQuery { Query = "TotalPrice_Range:{Ix100 TO NULL}" }, includes: new[] { "CustomerId" }); List <RavenJObject> orders = result.Results; List <RavenJObject> customers = result.Includes; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_8_6 Order2 order = session .Include <Order2, Supplier>(x => x.SupplierIds) .Load("order2s/1234"); foreach (Guid supplierId in order.SupplierIds) { // this will not require querying the server! Supplier supplier = session.Load <Supplier>(supplierId); } #endregion } } using (var store = new DocumentStore()) { #region includes_8_7 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "order2s/1234" }, includes: new[] { "SupplierIds" }); RavenJObject order = result.Results[0]; List <RavenJObject> suppliers = result.Includes; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_8_8 Order2 order = session .Include <Order2, Customer2>(x => x.Referral.CustomerId) .Load("order2s/1234"); // this will not require querying the server! Customer2 customer = session.Load <Customer2>(order.Referral.CustomerId); #endregion } } using (var store = new DocumentStore()) { #region includes_8_9 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "order2s/1234" }, includes: new[] { "Referral.CustomerId" }); RavenJObject order = result.Results[0]; RavenJObject customer = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_8_10 Order2 order = session .Include <Order2, Product>(x => x.LineItems.Select(li => li.ProductId)) .Load("orders/1234"); foreach (LineItem lineItem in order.LineItems) { // this will not require querying the server! Product product = session.Load <Product>(lineItem.ProductId); } #endregion } } using (var store = new DocumentStore()) { #region includes_8_11 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "order2s/1234" }, includes: new[] { "LineItems.,ProductId" }); RavenJObject order = result.Results[0]; List <RavenJObject> products = result.Includes; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_9_0 Order3 order = session .Include <Order3, Customer>(x => x.Customer.Id) .Load("orders/1234"); // this will not require querying the server! Customer customer = session.Load <Customer>(order.Customer.Id); #endregion } } using (var store = new DocumentStore()) { #region includes_9_1 MultiLoadResult result = store .DatabaseCommands .Get(ids: new[] { "orders/1234" }, includes: new[] { "Customer.Id" }); RavenJObject order = result.Results[0]; RavenJObject customer = result.Includes[0]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_10_0 session.Store( new Person { Id = "people/1", Name = "John Doe", Attributes = new Dictionary <string, string> { { "Mother", "people/2" }, { "Father", "people/3" } } }); session.Store( new Person { Id = "people/2", Name = "Helen Doe", Attributes = new Dictionary <string, string>() }); session.Store( new Person { Id = "people/3", Name = "George Doe", Attributes = new Dictionary <string, string>() }); #endregion } using (var session = store.OpenSession()) { #region includes_10_1 var person = session .Include <Person>(x => x.Attributes.Values) .Load("people/1"); var mother = session .Load <Person>(person.Attributes["Mother"]); var father = session .Load <Person>(person.Attributes["Father"]); Assert.Equal(1, session.Advanced.NumberOfRequests); #endregion } #region includes_10_2 var result = store .DatabaseCommands .Get(new[] { "people/1" }, new[] { "Attributes.$Values" }); var include1 = result.Includes[0]; var include2 = result.Includes[1]; #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_10_3 var person = session .Include <Person>(x => x.Attributes.Keys) .Load("people/1"); #endregion } #region includes_10_4 var result = store .DatabaseCommands .Get(new[] { "people/1" }, new[] { "Attributes.$Keys" }); #endregion } using (var store = new DocumentStore()) { using (var session = store.OpenSession()) { #region includes_11_0 session.Store( new PersonWithAttribute { Id = "people/1", Name = "John Doe", Attributes = new Dictionary <string, Attribute> { { "Mother", new Attribute { Ref = "people/2" } }, { "Father", new Attribute { Ref = "people/3" } } } }); session.Store( new Person { Id = "people/2", Name = "Helen Doe", Attributes = new Dictionary <string, string>() }); session.Store( new Person { Id = "people/3", Name = "George Doe", Attributes = new Dictionary <string, string>() }); #endregion } using (var session = store.OpenSession()) { #region includes_11_1 var person = session .Include <PersonWithAttribute>(x => x.Attributes.Values.Select(v => v.Ref)) .Load("people/1"); var mother = session .Load <Person>(person.Attributes["Mother"].Ref); var father = session .Load <Person>(person.Attributes["Father"].Ref); Assert.Equal(1, session.Advanced.NumberOfRequests); #endregion } #region includes_11_2 var result = store .DatabaseCommands .Get(new[] { "people/1" }, new[] { "Attributes.$Values,Ref" }); var include1 = result.Includes[0]; var include2 = result.Includes[1]; #endregion } }