Assigning an identifier vs object - linq to sql

Say that I have a Client object that has a relationship with a city, an order, etc. Now, when I add a client object, should I assign customer.cityid or customer.city? From the form, I get cityid from the drop-down list, so in order to assign a city object, I will need to make a request using the selected identifier.

+4
source share
1 answer

If you need a City object that is full, then get the city and install .City .

If you do not need a City object, and you just save and move on, setting .CityId without receiving the city object will save the selected request, receiving it.

In any case, the next time the object loads, City will appear. (Both methods store the same City column in the database unless you have something strange / non-standard).

+2
source

Source: https://habr.com/ru/post/1304782/


All Articles