Search for existing suggestions

Make DbDataReader available to ObjectMaterialized event handlers

In many cases, we use joins or custom queries to return additional related data for an entity. Its a bit of paint today to manipulate this custom data and load it into the entity selectively.

I have found a workaround using the Translate method on ObjectContext. Basically in such cases, we will execute the query manually and have the entities materialized using ObjectContext.Translate. Before invoking this method, we save the Reader in an instance variable for DbContext that is later available in ObjectMaterialized event.

This is working great, just that we need to ensure to use Translate when we need reader in ObjectMaterialized. From what I see in ObjectContext (using Reflector), the Shaper and other helps classes being used are holding a reference to DbDataReader. If the same can be exposed via an instance member for the ObjectMaterializedEventArgs parameter to ObjectMaterialized event, it would go a long way in helping execute custom materialization logics within the EF boundaries.

1 vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)

We’ll send you updates on this idea

Rahul Singla shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base