May 18th, 2021 (edited)
8 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 var lonlat = location.GetLonLatRcut(areatype, buffer);
  2.                 //здесь ММ & НГПТ
  3.                 var sql = $@"WITH routeobj AS (
  4.                                SELECT distinct r_1.id, r_1.""from"",r_1.""to"", r_1.number, r_1.rolling_stock_id
  5.                                    FROM dbo.""dblink""('dbname=rcut'::text,
  6.                                            'SELECT r.id, r.""from"", r.""to"", r.number, r.rolling_stock_id
  7.                                                FROM routes r, route_directions rd, rolling_stocks rs
  8.                                                WHERE r.close_date is null and rd.close_date is null and r.installation_id=''{ConfigHelperRcut.InstallationId}'' and r.id = rd.route_id and r.rolling_stock_id = rs.id and st_intersects(geo_data, {lonlat})'::text)
  9.                                    r_1(id uuid, ""from"" varchar, ""to"" varchar, number varchar, rolling_stock_id int)
  10.                                )
  11.                          SELECT o.""Id"" as EventObjectId, r.id, r.""from"", r.""to"", r.number, r.rolling_stock_id as rollingstockid
  12.                           FROM dbo.""EventObjects"" o join dbo.""ExternalEventObjects"" eeo on o.""Id""=eeo.""EventObject_Id""
  13. join dbo.""Externals"" e on e.""Id"" = eeo.""External_Id""
  14.                            right join routeobj r on e.""ExternalId"" = r.id and o.""DateOff"" is null;";
  16.                 var mM = context.Database.SqlQuery<Model.Virtual.RouteEventObject>(sql).ToArray();
RAW Paste Data