Skip to content

Outer Apply Situations - How to Handle "FOR JSON PATH" and "FOR XML PATH" #12

Description

@MichaelTimbes

Hi, I've been trying to figure out how to handle generating primarily JSON from an outer apply statement with SqlKata. The outer apply, I don't have issues with, but I'm not sure how to turn this query for example into a SqlKata version if possible, thanks!

SELECT
  c.ID
, c.Name
, pr.Name AS ProviderName
, FooSatelliteDetails.JsonValue
FROM Connections c WITH (NOLOCK)
INNER JOIN Provider pr ON pr.ID = pc.ProviderID
INNER JOIN FooSatelliteTable fst WITH (NOLOCK) ON fst.ConnectionID = pc.ID
CROSS APPLY (
	SELECT
	  fd.ID
	, fd.[Name]
	FROM FooSatelliteDetailTable fd 
	WHERE fd.RelatedSatelliteID = fst.ID
	FOR JSON PATH
)FooSatelliteDetails(JsonValue)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions