Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MichaelTimbes opened this issue Mar 2, 2023 · 0 comments

Comments

@MichaelTimbes
Copy link

MichaelTimbes commented Mar 2, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant