【发布时间】:2012-05-24 13:23:26
【问题描述】:
我有以下代码:
public class MyContext:DbContext
{
DbSet<ABFoo> ABFoo { get; set; }
DbSet<CDFoo> CDFoo { get; set; }
}
ABFoo 和 CDFoo 是具有相同成员的类。 我现在有这个查询:
var t = context.ABFoo.Where(a => a.ID == 10);
我想让 ABFoo 表以这种方式动态改变
var t = context.ABFoo.Where(a => a.ID == 10).OnThePrefixTable("CD");
即使在 ABFoo 表上执行查询,我也必须切换到 CDFoo 表。 我知道我必须使用 ExpressionVisistors 并更改“对象”,但不知道该怎么办! 非常感谢!
【问题讨论】:
-
你想把 ABFoo 中 ID = 10 的数据放到 CDFoo 表中,我明白了吗?
标签: c# .net linq entity-framework linq-to-entities