Search code examples
petapoco

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; 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?


Solution

  • I think so yes, maybe even cache it if the list values don't change.