I'm struggling a bit with generics and inheritance. Basically, I want this:
My problem: Currently I can't access the relation between CA and CB from the base classes, or the interfaces. However, if I define the relation there I won't have a typed relation between CA and CB anymore, making it significantly harder to query. I want an "untyped" relation between CBaseA and CBaseB, and a typed relation between any childs of CA and CB Is there any solution? Any straightforward solution? Writing a custom LINQ expression rewriter? (How? I can't find the compiler-attributes the manual mentions) Edit: I see I've missed some details: CBaseA, CBaseB, CA and CB are all abstract classes. My conclusion so far is that I need to keep the relation in the CA/CB-classes and then "wrap" it somehow in CBaseA/CBaseB (and the interfaces), and I need some kind of rewriting Edit2: My new conclusion is that I won't be able to take that route since the actual implementation is totally unknown at runtime.. As far as I'm concerned, I need to have to properties, one in a base class, and one in an inherited class, that are essentially the same, kind of a hard link in a file system. However, an attempt to do so gives me an exception about duplicate keys.. Now I'm thinking I might be able to declare the relationship in the base classes, and then add validation, properties and rewriters for the inherited classes to ensure type safety.. I think that should work? =) |