Reputation: 33954
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.
Upvotes: 1
Views: 388
Reputation: 364249
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.
Upvotes: 2