LINQ Select from dynamic tableName string

后端 未结 2 1862
忘掉有多难
忘掉有多难 2020-12-04 00:05

I want to get list of records from an entity model (I\'m using EF version 5) with a particular accountID. I\'m being supplied with the tableName string (this has to be dynam

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 00:52

    I built a DynamicRepository for a project I am working on. It uses generic methods exposed through EF along with dynamic linq. It might be helpful to look at that source code here:

    https://dynamicmvc.codeplex.com/SourceControl/latest#DynamicMVC/DynamicMVC/Data/DynamicRepository.cs

    You can query the entity framework metadata workspace to get the type for a given table name. This link might help: Get Tables and Relationships

提交回复
热议问题