开发者

Is there a way to get the CLR type from the Entity when using POCO support for the Entity Framework?

I am using the POCO support for entity framework v4. I would like to get the Type of the POCO class that is mapped to that entity. For example you can get ObjectStateEntry from the ObjectStateManager. Tha开发者_如何学Ct entry then has a reference to the entity. The Entity is of type object so it is useless until you cast it.

This is fine if you know what the type of the entity maybe at compile but what if you wanted it at runtime. Does the entity framework store anywhere the CLR type of that entity.


Yes, you can do:

var mappedType = MyObjectContext.GetObjectType(myEntity.GetType());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜