(Sorry for the double post, but I realized that the original post over in the EntityGraph-specific project has very little traffic - this appears to be the much better place)
I love the idea of the EntityGraph stuff in this project and it seems like it will do exactly what need... except in one specific case.
- Silverlight 4
- EF 4.1 with Code-First
- EntityGraph (via Nuget package)
Quick version of what I see as the problem with the EntityGraph code: calling the EntityGraph extension method (defined in Proxies.cs) to create my graph gives me back an instance of EntityGraph, but what I need is an instance of EntityGraph<TEntity>.
I believe it's more accurate to say that it gives me an instance of EntityGraph<Entity>, but my point remains - I need it to be EntityGraph<TEntity> (tee-entity, not entity). Or, to put it even more differently, EntityGraph<MyConcreteEntityType>
and not EntityGraph<Entity>.
Here's why. I'm using Caliburn.Micro because (in addition to many other things) it eliminates nearly 100% of the binding expression code that I would otherwise have to write. It uses controls' x:Name attributes to automatically set up the necessary binding
expressions. Again, in most cases I have exactly ZERO databinding code in my xaml files.
Pretty much everything I'm trying to bind in my UI starts with an instance of an EntityGraph object whose Source property is an instance of my root entity. The problem is that when Caliburn looks at the Source property of my EntityGraph object, it sees
that it is of type Entity, not "MyEntityTypeName". It uses reflection at runtime to make decisions about whether or not to apply my binding conventions, but because the root Entity from Ria Services doesn't have any of my entity's properties defined
on it, it elects to not create the bindings.
I've tried a couple of different approaches to working around this. First, before thinking things through, I tried to do this:
var foo = myEntity.EntityGraph(myShape)
But that fails to compile because there's no way to coerce something that's EntityGraph<Entity> into EntityGraph<MyEntityType>.
Then I tried inheriting from EntityGraphFactory and altering its Get method to return EntityGraph<TEntity>. This appeared impossible almost immediately, mainly because things like the factory instance were private.
Then I downloaded the code from this project and started hacking away. My thinking was that there would probably be no harm in just making it ALWAYS return the "very type-specific" version of EntityGraph (especially for my case), so I thought that
it would be pretty easy. However, the changes I needed to make keep spiraling out to more and more of the codebase, so I'm thinking that maybe I'm just looking at this the wrong way.
Is anyone aware of a way to get a graph with a source property of MY entity type rather than the RIA Services' base Entity type?