Say I have an entity Customer which has relationship with city, order etc. Now when I am adding a customer object, should I assign customer.cityid, or customer.city? From the form I get cityid from a dropdown, so to assign the city object, I will have to make a query using id selected.
+2
A:
If you need the City object populated, then get the City and set .City
.
If you don't need the City object and are just saving and moving on, setting .CityId
without getting the city object will save you the select query fetching it.
In either case, the next time the object loads, City will be available. (Both methods save the same City column in the database unless you have something strange/non-default setup).
Nick Craver
2010-03-22 16:17:15