1

I have this SP,

ALTER PROCEDURE [dbo].[GetPageByID]
(
    @ID INT
)
AS

    SELECT  P.*
            ,A.*
    FROM    Page P
            LEFT OUTER JOIN [dbo].[Application] A ON P.ApplicationVersion = A.[Version]
    WHERE   P.ID = @ID;

and I am using this code to load into objects,

        return context.Database.SqlQuery<Page>(@"EXEC GetPageByID {0}", new object[] { id }).FirstOrDefault();

This only loads properties of Page but not loading Page.Application property. Any way to tell EF to do this.

0

1 Answer 1

2

No. SqlQuery is able to load only the main entity you are asking for - in your case the Page. If you want to load children as well you cannot use SqlQuery. EF5 with EDMX provides mapping for stored procedures with multiple result sets (that means you will need stored procedure with two queries - one for pages and second for applications). It is not supported with code first yet.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.