C# Avoid Repetitive code and use Generic
<p>The subject might look like that this question is already been posted, but my code snippet and problem is different.
Please have a look at it.
I have some 20 to 22 Sql tables of which I have created my POCO class in my Application. Each of these tables have some 4-5 common columns to which I need to fill some records in the application,rest columns of the table are already filled by XML data sent by some other application. The only 4-5 common columns of each table I am trying to fill in the application as below.</p>

<pre><code>private List&lt;Software&gt; GetSoftwareEntityData(Information request, DateTime scanDateTime)
{
    List&lt;Software&gt; Data = new List&lt;Software&gt;();
    int SrNo = 0;
    foreach (var item in request.Software)
    {
        Software d = new Software();
        d = item;
        d.DCDTime = DateTime.Now;
        d.LastModDTime = scanDateTime;
        d.ID = request.Id;
        d.ScanDateTime = scanDateTime;
        d.SrNo = ++SrNo;
        Data.Add(d);
    }
    return Data;
}

private List&lt;Users&gt; GetUsersEntityData(Information request, DateTime scanDateTime)
{
    List&lt;Users&gt; Data = new List&lt;Users&gt;();
    int SrNo = 0;
    foreach (var item in request.Users)
    {
        Users d = new Users();
        d = item;
        d.DCDTime = DateTime.Now;
        d.LastModDTime = scanDateTime;
        d.ID = request.Id;
        d.ScanDateTime = scanDateTime;
        d.SrNo = ++SrNo;
        Data.Add(d);
    }
    return Data;
}
</code></pre>

<p>Similarly I have written code for 22 tables each and these functions are being called when I am dealing with that specific set of object.</p>

<p>How can I create a Generic method, so that I can get rid of 22 functions which have repetitive code?</p>

<p>I am posting my Information class also here below.</p>

<pre><code>public class Information
{
 public List&lt;Software&gt; Software{get;set;}
 public List&lt;Users&gt; Users{get;set;}
}
</code></pre>

<p>So now my Software and Users class looks like below with an interface implementation called ICommonColumns.</p>

<pre><code>public interface ICommonColumns
{
DateTime DCDTime{get;set;}
DateTime LastModDTime{get;set}
.....
and others common fields
}

public class Software : ICommonColumns
{
....
}

public class Users : ICommonColumns
{
....
}
</code></pre>