I have 3 models:

Projects

```
public int ProjectID { get; set; }
public string Description { get; set; }
public string UserID { get; set; }
[ForeignKey("UserID")]
public virtual ApplicationUser User { get; set; }

public virtual ICollection<Job> Jobs { get; set; }

```

Jobs

```
 public int JobID { get; set; }
    public int ProjectID { get; set; }
    public string Title { get; set; }
    public string Jobdescription { get; set; }
    public string UserID { get; set; }
    [ForeignKey("UserID")]
    public virtual ApplicationUser User { get; set; }

    public virtual Project Projects { get; set; }
    public virtual ICollection<Log> Logs { get; set; }
    public virtual ICollection<Assignment> Assignments { get; set; }

```

Logs

```
 public int LogID { get; set; }
    public int JobID { get; set; }
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm}")]
    public DateTime Logstart { get; set; }
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd HH:mm}")]
    public DateTime Logend { get; set; }
    public int totaltime { get; set; }
    public string Notes { get; set; }
    public string UserID { get; set; }
    [ForeignKey("UserID")]
    public virtual ApplicationUser User { get; set; }
    public virtual Job Job { get; set; }

```

I would like to have for example in my projects index view a sum of all 'totaltime' for all logs for each project. In my Job index page I can easily do this by summing those totals within a foreach loop like this in my view:

```
@TimeSpan.FromMinutes(item.Logs.Sum(i => i.totaltime))

```

However I don't know how to do the same thing on my projects page without either creating a viewmodel or adding the ProjectID key to the Logs model so that I can do the above for Projects on the projects index page.

I can get the totaltime value for the first job of each project using this:

```
@TimeSpan.FromMinutes(item.Jobs.Sum(i => i.Logs.First().totaltime))

```

However I don't know how I can write this to sum all of the 'totaltimes' for each job. 

What I would like to know is what is the best way to do this. Do I have to create a viewmodel or add a relationship to the project model in my log model in the fashion the project model relates to the job model. Are there downsides or issues with either of those methods that I might be missing? Surely there is a simple way for me to just attain the 'totaltime' for a project using something like I am using above?

I am as you might be able to tell just trying to slowly learn MVC. Thanks.