1

我正在将 LINQ to SQL 转换为 EntityFramework 5。在 LINQ to SQL 中,我使用了此函数,仅按其类型(VB-Code)获取表:

Dim type As Type = myObject.GetType()
Dim context As MyEntities = New MyEntities()
query = context.GetTable(type).AsQueryable()

现在我正在 EF5 中寻找一种相等的方法。我在 SO 上找到了这个答案,但我的上下文没有一个名为CreateObjectSet. 这是因为 EF4 和 EF5 之间的差异,还是我遗漏了什么?

4

1 回答 1

1

基于这个答案,我发现我可以使用Set而不是CreateObjectSet

Public Function GetTable(Of T As Class)(entity As T) As IQueryable
    Return dbContext.Set(Of T)()
End Function
于 2013-03-22T09:34:21.020 回答