// Create an instance of EntityRef EntityRefcustomerRef = new EntityRef (); // Set the reference to an existing customer object customerRef.Entity = existingCustomer; // Add the reference to a set EntitySet > customers = new EntitySet >(); customers.Add(customerRef);
// Create an instance of EntitySet EntitySetIn this example, we create an EntitySet of Order references. We create a new Order object and an EntityRef for it. We add the reference to the EntitySet and save the changes to the database. These examples use the Entity Framework library in C#.> orders = new EntitySet >(); // Create a new order object Order newOrder = new Order(); // Create a new EntityRef and set it to the new order object EntityRef orderRef = new EntityRef (); orderRef.Entity = newOrder; // Add the reference to the EntitySet orders.Add(orderRef); // Save the changes to the database context.SaveChanges();