Hi Mark

Thanks for that snip-it, I have it working now - very cool

Kirsten

  _____  

From: [email protected] [mailto:[email protected]]
On Behalf Of Mark Thompson
Sent: Monday, 13 December 2010 12:15 PM
To: 'ozDotNet'
Subject: RE: Entity Framework - select from stored procedures?

 

Hi Kirsten,

 

The parameters for your stored proc should appear as parameter names on the
method that gets created on your Entities object.  I just tested this out
with a simple 'SearchCustomers' stored proc which takes a varchar(50) as a
parameter. Once I've gone through the Add > Function Import screen to add
the stored proc to the enetity model, it can be called like this:

 

            var context = new TimeSheetsEntities();

            var results = context.SearchCustomers("smith");

            foreach (var customerResult in results)

            {

                Console.Write(customerResult.CustomerName);

            }

 

Here, the SearchCustomers method accepts one parameter, which matches up to
the parameter defined on the stored proc.

 

Regards,

Mark.

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Kirsten Greed
Sent: Monday, 13 December 2010 4:57 AM
To: 'ozDotNet'
Subject: RE: Entity Framework - select from stored procedures?

 

Hi Mark

Thanks for the link - I am doing what it says to create a complex type

However my stored procedure takes parameters.  I can't see where these get
supplied.  Without the parameters the stored proc returns a data structure
but no data.

Do you know how to get the technique working when the stored proc needs
parameters?

Thanks

Kirsten

 

  _____  

From: [email protected] [mailto:[email protected]]
On Behalf Of Mark Thompson
Sent: Sunday, 12 December 2010 9:41 PM
To: 'ozDotNet'
Subject: RE: Entity Framework - select from stored procedures?

 

Hi Kirsten,  I used Complex Types, but just let the designer do the work of
creating it for me.  This blog post shows an example of the whole process
from start to finish - I used the same technique outlined here and it all
worked as advertised:

 

http://beyondrelational.com/blogs/jalpesh/archive/2010/08/18/entity-framewor
k-4-0-bind-stored-procedure-with-result-entity-class.aspx 

 

Is this the kind of thing you were after?

 

-          Mark.

 

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Kirsten Greed
Sent: Sunday, 12 December 2010 5:10 PM
To: 'ozDotNet'
Subject: RE: Entity Framework - select from stored procedures?

 

Thanks Mark - were you using Complex Types?  I can't figure out how to
create a populated binding source from the stored proc.  

  _____  

From: [email protected] [mailto:[email protected]]
On Behalf Of Mark Thompson
Sent: Sunday, 12 December 2010 3:06 PM
To: 'ozDotNet'
Subject: RE: Entity Framework - select from stored procedures?

 

I used it on the last project I worked on - it all seemed to work as
advertised, and I don't remember there being any particular tricks or quirks
with it. Overall I've been pretty happy with EF4, although I'm sure many
will argue there are still better ORM's around.

 

Mark.

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Kirsten Greed
Sent: Sunday, 12 December 2010 10:28 AM
To: 'ozDotNet'
Subject: RE: Entity Framework - select from stored procedures?

 

Ah, I have found out I can map the output of stored procedures to complex
types using Entity Framework

Is any one out there using this technique?  Are you happy with it?

Thanks

Kirsten

  _____  

From: [email protected] [mailto:[email protected]]
On Behalf Of Kirsten Greed
Sent: Sunday, 12 December 2010 8:18 AM
To: 'ozDotNet'
Subject: Entity Framework - select from stored procedures?

 

Hi All

 

In my legacy VB6 code I use a stored procedure to return an ado recordset of
account customers with their aged amounts owing 

 

In the Dot Net upgrade, we are considering using Entity Framework

 

Is there a way to create objects from the output of a stored procedure? 

 

If not, I am wondering should I be creating extra fields in the customer
table to hold the calculated values?

 

Thanks

Kirsten



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5695 (20101211) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5695 (20101211) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5696 (20101212) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



__________ Information from ESET NOD32 Antivirus, version of virus signature
database 5697 (20101212) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Reply via email to