Hope you can help...
I have two SQL tables, one has users and the other has user locations that I need to combine into a C# datatable.
The basic query to join them isn't the issue, the problem is that a user may appear in the locations table more than once. In this case I need to pass each location to one row rather than list the user multiple times with multiple locations.
It is part of an ADO.NET proximity search so the current query stands as...
DECLARE @lat float
DECLARE @lon float
SET @lat = @varLat
SET @lon = @varLon
DECLARE @point geography = geography::Point(@lat, @lon, 4326);
DECLARE @distance float
SET @distance = @varDistance
SELECT t1.locationId, t1.city, t2.[firstName]+' '+[lastName] as name
FROM _Locations t1 INNER JOIN _Users t2 ON t2.userId = t1.userId
WHERE @point.STDistance(centerPoint) <= @distance
I feel like LINQ may help but it's not something I have used before.