Sorry about the delayed response. I just got back from vacation. Your CreateDashBoard method is not a create method if you have to pass the entity as a parameter. That would mean you have to create the entity outside of the method, which kind of defeats the purpose of the method, don't you think? Also, if the creation isn't asynchronous, just make the method synchronous.
public DBOARD CreateDashBoard()
{
var dashboard = new DBOARD();
// Optional initialization of the newly created entity.
entityManagerProvider.Manager.AddEntity(dashboard);
return dashboard;
}
As for the save method. If you return AlwaysCompletedOperationResult, the caller won't have any idea when the save is actually completed and whether it was successful or not. Also, if you don't override the default SaveOptions, don't bother with it. The save method should look like this.
public OperationResult<SaveResult> SaveAsync(Action<SaveResult> onSuccess = null, Action<Exception> onFail = null)
{
return entityManagerProvider.Manager
.SaveChangesAsync(op => op.OnComplete(onSuccess, onFail))
.AsOperationResult();
}
Finally, to relate entities, you simple add them to the respective navigation property/collection before you save, or set the applicable foreign key property to the correct key (not applicable for many-to-many).
For example as seen in TempHire, the following StaffingResource method relates a newly created address entity to the StaffingResource by simply adding it to the Addresses collection.
public Address AddAddress(AddressType type)
{
Address address = Address.Create(type);
Addresses.Add(address);
return address;
}