How to use repeated get data from table from one place by using general function take table name or any solution .

I get data from table reference but there different on table name selected from this table . so that i will use same get data statement on more controller so that to prevent repeated get data i think to put this on one place by general function or any concept prevent repeated but i cannot do that .

on controller actione of employeecontroller

Code:
var result = await _context.ReferenceFiles.Where(r => r.TableName == "Employees").ToListAsync();
            ViewBag.RefList = result;
on controller actione of Itemcontroller

Code:
var result = await _context.ReferenceFiles.Where(r => r.TableName == "Items").ToListAsync();
            ViewBag.RefList = result;
on view

Code:
 @foreach (var itemes in ViewBag.RefList)

{
    <thead>

            @itemes.FieldName

</thead>
}
Table Reference have 3 fields

code

FieldName

TableName