Not sure what the issue is, but your code above doesn't show where your 'person' value comes from.
In NorthwindIB, Order and Customer are related 0-1. The following code works fine, and reports 1 entity saved. (I've removed the statements that produce the output, as they're specific to my app.)
public void Test1to1AddAndSave() {
var customersQuery = _em1.Customers
.Where(c => c.ContactTitle == "Sales Representative")
.OrderBy(c => c.CompanyName);
_em1.ExecuteQueryAsync<Customer>(customersQuery, GotCustomers, null);
}
private void GotCustomers(EntityQueryOperation<Customer> args) {
Order newOrder = _em1.CreateEntity<Order>();
newOrder.OrderDate = DateTime.Today;
newOrder.Customer = args.Results.FirstOrDefault();
_em1.SaveChangesAsync(op => {
if (op.HasError) {
// output error message
}
else {
// output count of entities saved // reports "1"
}
}, null);
}
|