ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 278.1k

How to use repeated get data from table from one place by us

Dec 29 2018 6:48 PM
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
  1. var result = await _context.ReferenceFiles.Where(r => r.TableName == "Employees").ToListAsync();  
  2. ViewBag.RefList = result;  
on controller actione of Itemcontroller
  1. var result = await _context.ReferenceFiles.Where(r => r.TableName == "Items").ToListAsync();    
  2. ViewBag.RefList = result;    
  3. on view    
  4. @foreach (var itemes in ViewBag.RefList)    
  5. {    
  6. <thead>    
  7. @itemes.FieldName    
  8. </thead>    
  9. }    
Table Reference have 3 fields
 
code
FieldName
TableName 

Answers (1)