PetaPoco queries in a ViewModel
If I had a viewmodel that looked something like this
public class AddressViewModel
{
public int AddressID {get;set;}
public string Street {get;set;}
public string Town {get;set;}
public SelectList Countries { get;开发者_Python百科 set; }
}
How would I go about populating this?
Would it be 2 queries to the database, 1 to populate the address info and another to return all countries into the SelectList?
I think so yes, maybe even cache it if the list values don't change.
精彩评论