Is there a shortcut to convert a model to a view model?
<p>I am new to c# and .NET. I am learning ASP.NET MVC 5. One thing that I am finding myself spending extra time doing in converting a model to a viewmodel.</p>

<p>Here is my model</p>

<pre><code>public class Overview
{

    public string chain_name { get; set; }
    public int store_id { get; set; }
    public int total_attempts { get; set; }
    public int total_unique_number_called { get; set;  }
    public int total_callable { get; set; }
    public int total_completed_interviews { get; set; }

}
</code></pre>

<p>and here is my view model</p>

<pre><code>public class OverviewViewModel
{

    public string chain_name { get; set; }
    public int store_id { get; set; }
    public int total_attempts { get; set; }
    public int total_unique_number_called { get; set; }
    public int total_callable { get; set; }
    public int total_completed_interviews { get; set; }
    public decimal? unique_number_per_complete { get; set; }

    public OverviewViewModel()
    {
        unique_number_per_complete = 0;
    }

}
</code></pre>

<p>as you can see both Model and ViewModel are identical except for over variable which is a calculation.</p>

<p>To populate my view model I do the following</p>

<pre><code>var records = conn.Database.SqlQuery&lt;Overview&gt;(query).ToList();

var overView = new List&lt;OverviewViewModel&gt;();

foreach(var record in records){

    var newRecord = new OverviewViewModel();

    newRecord.store_id = record.store_id;

    newRecord.chain_name = record.chain_name;

    newRecord.total_attempts = record.total_attempts;

    newRecord.total_callable = record.total_callable;

    newRecord.total_completed_interviews = record.total_completed_interviews;

    if (record.total_completed_interviews &gt; 0) {
        newRecord.total_unique_number_called = record.total_unique_number_called / record.total_completed_interviews;
    }

    overView.Add(newRecord);
}
</code></pre>

<p>The two issues that I am seeing with my approach is that </p>

<ol>
<li>I have to do lots of extra coding especially of the view model is large or f I have multiple variables that I need to calculate.</li>
<li>I feel I am looping 1 extra time to convert my model to view mode.</li>
</ol>

<p>Is there an easier way to do this in c#?</p>

<p>Is there a better approach with this procedure for a large application? My goal is to learn the better way to utilize my code time to the fullest.</p>