问题描述
如何使用通用函数取表名从一个地方重复获取数据。
问题:
i使用重复更多声明来获取数据
实际上我需要从一个地方调用它,如果可能的话
但是不能这样做。
所以我不会去每个控制器并重复从参考文件中获取数据
i需要一个普通的地方来按功能或任何其他概念来调用它
如果可能的话怎么做。
我尝试过:
关于employeecontroller的控制器操作e
how to use repeated get data from table from one place by using general function take table name.
Problem:
i use repeated more statement to get data
actually i need to call it from one place if possible
but cannot do that.
so that i will not go every controller and repeat get data from reference file
i need one general place to call it by function or any other concept
how to do that if possible.
What I have tried:
on controller action e of employeecontroller
var result = await _context.ReferenceFiles.Where(r => r.TableName == "Employees").ToListAsync();
ViewBag.RefList = result;
on controller actione of Itemcontroller
var result = await _context.ReferenceFiles.Where(r => r.TableName == "Items").ToListAsync();
ViewBag.RefList = result;
查看
on view
@foreach (var itemes in ViewBag.RefList)
{
<thead>
@itemes.FieldName
</thead>
}
推荐答案
这篇关于如何使用通用函数取表名或任何解决方案从一个地方重复获取表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!