【发布时间】:2017-04-19 12:34:46
【问题描述】:
如果我通过Entity Framework Database First 生成我的实体,并且我想使用这样的函数:
AuditManager.DefaultConfiguration.Exclude<T>();
考虑到我想调用它的次数应该等于实体的数量
例如:
AuditManager.DefaultConfiguration.Exclude<Employee>();
AuditManager.DefaultConfiguration.Exclude<Department>();
AuditManager.DefaultConfiguration.Exclude<Room>();
现在如何遍历选定数量的实体并将每个实体传递给Exclude 函数?
【问题讨论】:
-
您没有将实体传递给泛型函数,而是将 entity-types 传递给泛型函数。
-
@Maarten:你是对的,如何创建实体类型列表并将项目传递给通用函数?
-
这听起来像是一个 X-Y 问题,你到底想在这里实现什么?
-
@Maarten : 它尝试以下
List<Type> types = new List<Type>(); types.Add(typeof(Employee));但不能使用types[0]作为函数参数 -
@DavidG : 我想控制应该通过该功能排除的实体,管理员用户应该选择一组实体,我想将这些实体传递给
exclude function以将它们排除在审计之外
标签: c# .net entity-framework generics entity-framework-plus