New Posts New Posts RSS Feed: EDMX ComplexType and Stored procedure support
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EDMX ComplexType and Stored procedure support

 Post Reply Post Reply
Author
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Topic: EDMX ComplexType and Stored procedure support
    Posted: 30-Dec-2008 at 2:20am

Thank-you Kim!

Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 29-Dec-2008 at 12:58pm
Here's a sample EDMX for a stored proc called "SalesbyYear".  This sproc is not in the NorthwindIB sample database unfortunately, so the SQL to generate it is also included in the zip.
 
Irritating, but true - the fake EntityType will be removed from the storage model, along with the mapping, any time you update the model from the database.   This is a limitation of the EF v1 designer.
 
Back to Top
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Posted: 28-Dec-2008 at 8:09pm
Yes, it will be great if you can supply a sample, just a simple one without the insert/update/delete stored procs, only a stored proc joining together a few tables and return the result set. Oh, btw, will the "fake" EntityTypes defined manually in edmx going to be removed everytime we update model from database (hope not) ?
 
Cheers
Sebastian
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 28-Dec-2008 at 5:00pm

Sebastian, I'm not sure I understand - are you trying to use a ComplexType as the sproc return type here?  Per the thread you referenced, that's not supported in EF v1 or DevForce EF.

If you don't want to map to a ComplexType, what you need to do is create a "fake" EntityType in both your conceptual and storage models shaped like the returned data.  You can't do this (at least not the SSDL EntityTpe) using the designer - you'll need to work in the EDMX directly.  We can put together a sample showing what this looks like if you think that would help.
 
Back to Top
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Posted: 26-Dec-2008 at 11:09pm
Hi,
 
This is a general question not specifically pertaining to DevForce EF, but more to MS ADO.NET EF.
 
 
I have a stored procedure that joins several tables and returns a result set, hypothetical example:
 
ALTER PROCEDURE [dbo].[GetBlaBlaBlaHistory]
    @EmployeeId uniqueidentifier
AS 
    
    SET NOCOUNT ON;
    SELECT ae.InternalId, e.FirstName, e.LastName, tv.Title, tv.Version, a.StartDateTime, a.EndDateTime, bct.Name 'AppointmentStatus'
    FROM RelatedEmployee ae
        INNER JOIN TableE e ON ae.EmployeeId = e.InternalId
        INNER JOIN TableA a ON ae.AppointmentId = a.InternalId 
        INNER JOIN TableBCT bct ON ae.AppointmentStatus = bct.InternalId
        INNER JOIN TableATV atv ON atv.AppointmentId = a.InternalId
        INNER JOIN TableTV tv ON tv.InternalId = atv.TrainingVersionId
    WHERE ae.EmployeeId = @EmployeeId
        AND ae.Status = 0
        AND e.Status = 0
        AND a.Status = 0
        AND bct.Name != 'Scheduled'
    ORDER BY a.EndDateTime DESC; 
 
Using just the steps from DevForce EF Developers Guide on Store Procedure Queries, page 215, I am not able to build and run, unless the resulting entityset maps to "something with metadata", as in either table or view.
 
At this point, I cannot use stored procedure queries, I can only use sql view.
 
Has anyone has similar stored proc issues like this?
 
Thanks!
Sebastian
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down