This needs to be a SQL view for C# to consume. I am sure there is a better way to write this, but I am not aware of how to do it.
[code language="sql"]
SELECT S.Id,
 
[code language="sql"]
SELECT S.Id,