views:

20

answers:

1

I am using the latest beta of Visual Studio 2010 and the Entity Framework. It's mostly really neat, but here's my situation:

  • I have a table T with columns Id and Name.
  • I have an auto-generated entity with Id and Name properties.
  • Finally, I have a stored procedure that selects only Id from T.

Trying to map my entity to the stored procedure results in an EntityCommandExecutionException:

A member of [the entity], 'Name', does not have a corresponding column in the data reader with the same name.

That makes sense, but is there some way to partially populate my entity from the stored procedure call and then fully materialize it later with a second query?

Nine months ago, the answer to this question appeared to involve a great deal of manual labor. In my case, we have hundreds of stored procedures, and literally none of them return full rows. The Entity Framework has come a long way since then, so I am hoping something might've changed.

Thank you in advance for any help!

+1  A: 

One approach might be to map the procedure results into a complex type, and then customize the code generation to add a method to this type which will materialize the entire object.

One possible hitch with this idea is that I'm not sure it's possible to customize code generation for complex types. You can certainly customize code generation for entity types, as explained in great detail in this post. It seems like you should be able to customize complex types, as well, but I've never tried it.

Craig Stuntz