开发者

Using Generics with a Parent/Child entities

I have a entity A and a entity B. B Inherits from A and is a superset of A. I have a method on the .ascx that currently loads control properties and binds the data from the A entity. I would like to expand the method to include B. I think I would need to create an entity that contains all of the fields from both and then cast the A or B to the Combined entity type. Anyon开发者_运维技巧e have any other suggestions?


If I understand your question, I would avoid the casting and instead create a BindB(B b) method that passes the object to the existing Bind(A a) method (no cast required thanks to morphism), then performs the additional binding for the B properties. The method you are suggesting will require a cast to the "super-object" before calling, only to operate conditionally on data you just hid (the actual type of the object). Doesn't make much sense.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜