tags:

views:

39

answers:

1

Hi all,

Suppose i have the following class.

public class Location
{
    public Id { get; set;}
    public Name { get; set;}
}

And i have a WebPage called Location that looks like this.

txtId  
txtName 

txtCountStaffWorkersAtLocation 
txtCountVehiclesAtLocation
txtCountNonStaffWorkersAtLocation 
txtCountetc

listViewPersonnel
listViewVehicles

Right now i'm calling a repository to display the Location fields on the view, but i'm confused as to what the correct method would be to get and display the data for the other fields. They obviously have very little to do do with the Location Class. Do i put the Counts in the Location Class and fill them in when i set up the Location class from the database? Do i have a struct object somewhere that has just has these count fields? What do you guys normally do with object being displayed on a page that have very little to do with the Domain Object?

Thanks

A: 

I'd recommend implementing StaffPersonnel, NonStaffPersonnel, and Vehicles as properties on the Location object, with each of those properties returning a collection of the associated objects. Then for the counts, you could properties from a location object as follows:

loc.Vehicles.Count
loc.StaffPersonnel.Count
loc.NonStaffPersonnel.Count
Adam Alexander