Skip to content
This repository has been archived by the owner on May 10, 2020. It is now read-only.

Set other side of a relationship automatically #11

Open
chanan opened this issue Jun 2, 2018 · 0 comments
Open

Set other side of a relationship automatically #11

chanan opened this issue Jun 2, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@chanan
Copy link
Owner

chanan commented Jun 2, 2018

For example:

var person = new Person { FirstName = "Many", LastName = "Test" };
var address1 = new Address { Street = "Many test 1", City = "Saved as a reference" };
var address2 = new Address { Street = "Many test 2", City = "Saved as a reference" };
person.OtherAddresses = new List<Address> { address1, address2 };
Context.People.Add(person);
Context.SaveChanges();

Right now, in the above code snippet there is no navigation property from Address to Person. If one was added to Address it would have to be manually set to the person instance:

var person = new Person { FirstName = "Many", LastName = "Test" };
var address1 = new Address { Street = "Many test 1", City = "Saved as a reference", Person = person };
var address2 = new Address { Street = "Many test 2", City = "Saved as a reference", Person = person };
person.OtherAddresses = new List<Address> { address1, address2 };
Context.People.Add(person);
Context.SaveChanges();

Make this automatic in SaveChanges()

@chanan chanan added the enhancement New feature or request label Jun 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant