Advertisement
Guest User

Untitled

a guest
Jul 18th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.39 KB | Source Code | 0 0
  1.        using var connection = _sqlConnectionFactory.CreateConnection();
  2.  
  3.        const string sql = """
  4.           SELECT
  5.               a.id AS Id,
  6.               a.last_modified_date_on_utc AS LastModifiedDateOnUtc,
  7.               a.last_modified_by AS LastModifiedBy,
  8.               a.created_on_utc AS CreatedOnUtc,
  9.               a.created_by AS CreatedBy,
  10.               a.type_of_request AS TypeOfRequest,
  11.               a.customs_clearance AS CustomsClearance,
  12.               a.delivery_conditions AS DeliveryConditions,
  13.               a.cargo_readiness_period AS CargoReadinessPeriod,
  14.               a.deadline_for_submitting_commercial_offer AS DeadlineForSubmittingCommercialOffer,
  15.               a.type_of_cargo AS TypeOfCargo,
  16.               a.type_of_packaging AS TypeOfPackaging,
  17.               a.container_type AS ContainerType,
  18.               a.places_in_container AS PlacesInContainer,
  19.               a.loading_in_one_container_net AS LoadingInOneContainerNeT,
  20.               a.number_of_containers AS NumberOfContainers,
  21.               a.weight_of_one_place AS WeightOfOnePlace,
  22.               a.loading_per_container_gross_ton AS LoadingPerContainerGrossTon,  
  23.               a.port_of_shipment AS PortOfShipment,
  24.               a.transshipment_port AS TransshipmentPort,
  25.               a.place_of_delivery AS PlaceOfDelivery,
  26.               a.cargo_pickup_address AS CargoPickupAddress,
  27.               a.note AS Note,
  28.               a.is_visible AS IsVisible,
  29.               a.index AS Index
  30.           FROM transportation_request AS a
  31.           """;
  32.  
  33.        var transportationRequestResponse = await connection.QueryAsync<GetTransportationRequestResponse>(
  34.            sql,
  35.            new[]
  36.            {
  37.                typeof(Guid),
  38.                typeof(Audit),
  39.                typeof(TypeOfRequest),
  40.                typeof(LogisticsProcess),
  41.                typeof(CargoCharacteristics),
  42.                typeof(CharacteristicsOfTheContainer),
  43.                typeof(LogisticsHubs),
  44.                typeof(string),
  45.                typeof(bool),
  46.            },
  47.            objects =>
  48.            {
  49.                Guid id = (Guid)objects[0];
  50.                Audit audit = (Audit)objects[1];
  51.                TypeOfRequest typeOfRequest = (TypeOfRequest)objects[2];
  52.                LogisticsProcess logisticsProcess = (LogisticsProcess)objects[3];
  53.                CargoCharacteristics cargoCharacteristics = (CargoCharacteristics)objects[4];
  54.                CharacteristicsOfTheContainer characteristicsOfTheContainer = (CharacteristicsOfTheContainer)objects[5];
  55.                LogisticsHubs logisticsHubs = (LogisticsHubs)objects[6];
  56.                string note = (string)objects[7];
  57.                bool isVisible = (bool)objects[8];
  58.  
  59.                GetTransportationRequestResponse getTransportationRequestResponse = new(
  60.                    id,
  61.                    audit,
  62.                    typeOfRequest,
  63.                    logisticsProcess,
  64.                    cargoCharacteristics,
  65.                    characteristicsOfTheContainer,
  66.                    logisticsHubs,
  67.                    note,
  68.                    isVisible);
  69.  
  70.                return getTransportationRequestResponse;
  71.  
  72.            },
  73.            splitOn: "Id,LastModifiedDateOnUtc,TypeOfRequest,CustomsClearance,TypeOfCargo,ContainerType,PortOfShipment,Note,IsVisible");
  74.  
  75.        
  76.        return transportationRequestResponse.ToList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement