问题描述
我有一个dbContext类,例如,其中编写了两个DbSet参数来处理两个表。
public EntityCoreContext()
{
}
public EntityCoreContext(DbContextOptions<EntityCoreContext> options)
: base(options)
{
}
public virtual DbSet<Languages> Languages { get; set; }
public virtual DbSet<Users> Users { get; set; }
我知道要从上下文中获取数据,我必须编写:dbContext.Users.ToList ();
或 dbContext.Languages.ToList();
我需要这样做,这样我才能获得数据而无需直接通过其名称调用表。从系列中:
dbContext.Get<Users>().ToList();
或dbContext.Get<Languages>().ToList();
嗯,或者用另一种方式。因此,表调用的方法是通用的。并且支持所有将传递给他的表。必须使用以下方法完成此操作:插入,更新,获取,删除。
解决方法
在EntityFramework中,存在.Set<T>()
method,其中根据所传递的类型返回DbSet
。
因此您可以使用:
dbContext.Set<Users>().ToList();
我知道这是奇怪的命名,但是这里的Set
方法返回了DbSet
,它没有设置任何内容。
不确定好处是什么,但类似这样:
var columnCellInEdit ={};
onCellEditingStarted: function(event) {
columnCellInEdit.columnId = event.column.colId;
columnCellInEdit.rowNodeId = event.node.id;
console.log('cellEditingStarted');
},// If you dont like the above approach then use below piece
// of code in your tooltip renderer
var cellDefs = gridOptions.api.getEditingCells();
cellDefs.forEach(function(cellDef) {
// use colid and rowIndex to confirm that the cell is being edited and not to show tooltip
console.log(cellDef.rowIndex);
console.log(cellDef.column.getId());