Accessing Entity Framework V4 properties in a weakly typed fashion
I am trying to determine if there is a way to access entity framework entity properties in a weakly typed fa开发者_StackOverflow中文版shion.
Instead of accessing the description property this way: myEntity.Description
I would really like to access it using an indexer: myEntity["Description"]
I have looked at the object model. The ObjectContext.Translate<>() method takes a DbDataReader but I have not found a way to access the DbDataReader, DataRow, etc...
Any help would be greatly appreciated.
Thanks, ...Marc
You can extend T4 template and to do it for you. You can either do it by reflection (slow, bad) or use silly (but fast) approach with switch
.
You can use EntityClient which streams results as an EntityDataReader which as the name suggests is an implementation of DbDataReader.
精彩评论