Linq to SQL Stored Procedures with Multiple Results

前端 未结 3 1311
情深已故
情深已故 2020-12-14 10:27

We have followed the approach below to get the data from multiple results using LINQ To SQL

CREATE PROCEDURE dbo.GetPostByID
(
    @PostID int
)
AS
    SELEC         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 10:40

    Just curious, if a Post have have one or many Categories, is it possible to instead of using the for loop, to load the Post.PostCategories with the list of Categories (one to many), all in one shot, using a JOIN?

    var rslt = from p in results.GetResult()
               join c in results.GetResult() on p.PostId = c.PostID
               ...
               p.Categories.Add(c)
    

提交回复
热议问题