Some questions about the .NET Entity Framework and Stored Procedures

Posted by Bara on Stack Overflow See other posts from Stack Overflow or by Bara
Published on 2010-05-26T22:10:43Z Indexed on 2010/05/26 22:51 UTC
Read the original article Hit count: 233

Hey everyone, I had a couple of questions relating to the .NET Entity Framework and using stored procedures. Here goes:

  1. I know that we can right click a stored procedure and choose Function Import to be able to use with code. Is there a way to do this for many stored procedures at once?

  2. When doing a Function Import, I can create a new Complex type or use an existing Complex type. Well, how can I access Complex types/objects that are outside of the edmx file? That is, if I have a class in my project, is it possible to access it while doing a Function Import?

  3. When calling the stored procedure from code, it returns an IEnumerable of the Complex type I set it as. However, sometimes these complex types do not have all of the properties that I need, so I create a new class in my project that inherits from the complex type used in the stored procedure. Problem is, I can't seem to cast the complex type returned from the stored procedure to the new class I created. Any reason why I can't do this? What I ended up doing is looping through the IEnumerable and adding each item to a new list of the class that I created. But this feels and looks messy.

Bara

© Stack Overflow or respective owner

Related posts about .NET

Related posts about entity-framework