Ошибка при попытке сопоставить объекты в Dapper (ошибка нескольких карт: столбец SplitOn)

Ошибка: System.ArgumentException: ошибка нескольких карт: столбец SplitOn «Идентификатор» не найден. Убедитесь, что ваш параметр SplitOn установлен и находится в правильном порядке (параметр «splitOn»).

Это происходит, когда я использую проверку IdentityRoles в роли администратора. Если убрать все проверки и всю логику по этому поводу, то все начинает работать. См. примеры ниже.

Код GetTransportationRequestQueryHandler:

internal sealed class GetTransportationRequestQueryHandler
    : IQueryHandler<GetTransportationRequestQuery, IReadOnlyList<GetTransportationRequestResponse>>
{
    private readonly ISqlConnectionFactory _sqlConnectionFactory;

    public GetTransportationRequestQueryHandler(ISqlConnectionFactory sqlConnectionFactory)
    {
        _sqlConnectionFactory = sqlConnectionFactory;
    }

    public async Task<Result<IReadOnlyList<GetTransportationRequestResponse>>> Handle(
        GetTransportationRequestQuery request, CancellationToken cancellationToken)
    {
        string sqlString =
               """
               SELECT
                   a.id AS Id,
                   a.created_by AS CreatedBy, 
                   a.created_on_utc AS CreatedOnUtc,
                   a.last_modified_date_on_utc AS LastModifiedDateOnUtc,
                   a.last_modified_by AS LastModifiedBy,
                   a.type_of_request AS TypeOfRequest,
                   a.customs_clearance AS CustomsClearance,
                   a.delivery_conditions AS DeliveryConditions,
                   a.cargo_readiness_period AS CargoReadinessPeriod,
                   a.deadline_for_submitting_commercial_offer AS DeadlineForSubmittingCommercialOffer,
                   a.type_of_cargo AS TypeOfCargo,
                   a.type_of_packaging AS TypeOfPackaging,
                   a.container_type AS ContainerType,
                   a.places_in_container AS PlacesInContainer,
                   a.loading_in_one_container_net AS LoadingInOneContainerNeT,
                   a.number_of_containers AS NumberOfContainers,
                   a.weight_of_one_place AS WeightOfOnePlace,
                   a.loading_per_container_gross_ton AS LoadingPerContainerGrossTon,  
                   a.port_of_shipment AS PortOfShipment,
                   a.transshipment_port AS TransshipmentPort,
                   a.place_of_delivery AS PlaceOfDelivery,
                   a.cargo_pickup_address AS CargoPickupAddress,
                   a.note AS Note,
                   a.is_visible AS IsVisible,
                   a.index AS Index
               FROM transportation_request AS a
               """;

        if (!request.IdentityUser.IdentityRoles.Contains("Administrator"))
        {
            var firstIndexOfWord = IndexOfFirstLetter(sqlString, "a.created_by");
            var lastIndexOfWord = IndexOfLastLetter(sqlString, "LastModifiedBy,\r\n    ");
            sqlString = sqlString.Remove(firstIndexOfWord, lastIndexOfWord - firstIndexOfWord);
        }

        using var connection = _sqlConnectionFactory.CreateConnection();

        var transportationRequestResponse = await connection.QueryAsync<GetTransportationRequestResponse>(
            sqlString,
            new[]
            {
                typeof(Guid),
                request.IdentityUser.IdentityRoles.Contains("Administrator") ? null : typeof(Audit),
                typeof(TypeOfRequest),
                typeof(LogisticsProcess),
                typeof(CargoCharacteristics),
                typeof(CharacteristicsOfTheContainer),
                typeof(LogisticsHubs),
                typeof(string),
                typeof(bool),
            },
            objects =>
            {
                Guid id = (Guid)objects[0];
                Audit? audit = (Audit)objects[1];
                TypeOfRequest typeOfRequest = (TypeOfRequest)objects[2];
                LogisticsProcess logisticsProcess = (LogisticsProcess)objects[3];
                CargoCharacteristics cargoCharacteristics = (CargoCharacteristics)objects[4];
                CharacteristicsOfTheContainer characteristicsOfTheContainer = (CharacteristicsOfTheContainer)objects[5];
                LogisticsHubs logisticsHubs = (LogisticsHubs)objects[6];
                string note = (string)objects[7];
                bool isVisible = (bool)objects[8];

                GetTransportationRequestResponse getTransportationRequestResponse = new(
                id,
                audit,
                typeOfRequest,
                logisticsProcess,
                cargoCharacteristics,
                characteristicsOfTheContainer,
                logisticsHubs,
                note,
                isVisible);

                return getTransportationRequestResponse;
            },
            splitOn: $"Id{(request.IdentityUser.IdentityRoles.Contains("Administrator") ? ",CreatedBy," : ",")}TypeOfRequest,CustomsClearance,TypeOfCargo,ContainerType,PortOfShipment,Note,IsVisible");         
           

        return transportationRequestResponse.ToList();
    }`

Код метода IndexOfFirstLetter:

int IndexOfFirstLetter(string str, string word)
{
    var stringCharArray = str.ToCharArray();
    var wordCharArray = word.ToCharArray();

    int wordLength = wordCharArray.Length;
    int wordIndex = 0;
    int coincidenceCounter = 0;
    int tmpValueForWordIndex = 0;
    int counterForWhile = 0;

    for (int i = 0; i < stringCharArray.Length; i++)
    {
        while (counterForWhile < wordLength)
        {
            if (stringCharArray[i] == wordCharArray[counterForWhile])
            {
                tmpValueForWordIndex = i;
                ++coincidenceCounter;
                counterForWhile++;

                if (coincidenceCounter == wordLength)
                {
                    wordIndex = tmpValueForWordIndex - (wordLength - 1);
                }
                break;
            }
            if (stringCharArray[i] != wordCharArray[counterForWhile])
            {
                coincidenceCounter = 0;
                counterForWhile = 0;
                break;
            }
        }
    }

    return wordIndex;
}

Код метода IndexOfLastLetter:

int IndexOfLastLetter(string str, string word)
{
    var stringCharArray = str.ToCharArray();
    var wordCharArray = word.ToCharArray();

    int wordLength = wordCharArray.Length;
    int wordIndex = 0;
    int coincidenceCounter = 0;
    int tmpValueForWordIndex = 0;
    int counterForWhile = 0;

    for (int i = 0; i < stringCharArray.Length; i++)
    {
        while (counterForWhile < wordLength)
        {
            if (stringCharArray[i] == wordCharArray[counterForWhile])
            {
                tmpValueForWordIndex = i;
                ++coincidenceCounter;
                counterForWhile++;

                if (coincidenceCounter == wordLength)
                {
                    wordIndex = tmpValueForWordIndex;
                }

                break;
            }
            if (stringCharArray[i] != wordCharArray[counterForWhile])
            {
                coincidenceCounter = 0;
                counterForWhile = 0;
                break;
            }
        }
    }

    return wordIndex;
}

Этот фрагмент кода удаляет часть строки sql, если нет роли администратора.

if (!request.IdentityUser.IdentityRoles.Contains("Administrator"))
{
    var firstIndexOfWord = IndexOfFirstLetter(sqlString, "a.created_by");
    var lastIndexOfWord = IndexOfLastLetter(sqlString, "LastModifiedBy,\r\n    ");
    sqlString = sqlString.Remove(firstIndexOfWord, lastIndexOfWord - firstIndexOfWord);
}

После удаления строка sql выглядит так, и этот запрос sql верен:

SELECT
    a.id AS Id,
     a.type_of_request AS TypeOfRequest,
    a.customs_clearance AS CustomsClearance,
    a.delivery_conditions AS DeliveryConditions,
    a.cargo_readiness_period AS CargoReadinessPeriod,
    a.deadline_for_submitting_commercial_offer AS DeadlineForSubmittingCommercialOffer,
    a.type_of_cargo AS TypeOfCargo,
    a.type_of_packaging AS TypeOfPackaging,
    a.container_type AS ContainerType,
    a.places_in_container AS PlacesInContainer,
    a.loading_in_one_container_net AS LoadingInOneContainerNeT,
    a.number_of_containers AS NumberOfContainers,
    a.weight_of_one_place AS WeightOfOnePlace,
    a.loading_per_container_gross_ton AS LoadingPerContainerGrossTon,  
    a.port_of_shipment AS PortOfShipment,
    a.transshipment_port AS TransshipmentPort,
    a.place_of_delivery AS PlaceOfDelivery,
    a.cargo_pickup_address AS CargoPickupAddress,
    a.note AS Note,
    a.is_visible AS IsVisible,
    a.index AS Index
FROM transportation_request AS a
{
    "records": [
        {
            "id": "872e32ac-cbe7-4d7d-8365-b6b1b4505968",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 1
        },
        {
            "id": "d9e12d31-f719-48f0-a29c-d64ea54d0af8",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 2
        },
        {
            "id": "e42d9993-3410-4a41-9ee9-7a1ce5791776",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 4
        },
        {
            "id": "39cbdfff-79d7-41d6-938d-10071552fd1b",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 5
        },
        {
            "id": "6b1285f5-e554-458d-9d23-f3180538a548",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 6
        },
        {
            "id": "c5945a77-5e7f-476a-9645-fa860de0bd46",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 7
        },
        {
            "id": "4697e6d1-64cc-4df0-b2f8-60666e3cd462",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 8
        },
        {
            "id": "11132681-ad4e-4b48-90a0-5d48cffd9580",
            "typeofrequest": 1,
            "customsclearance": "string",
            "deliveryconditions": "string",
            "cargoreadinessperiod": "2024-07-16",
            "deadlineforsubmittingcommercialoffer": "2024-07-16",
            "typeofcargo": "string",
            "typeofpackaging": "string",
            "containertype": "string",
            "placesincontainer": 123,
            "loadinginonecontainernet": 23,
            "numberofcontainers": 14,
            "weightofoneplace": 2,
            "loadingpercontainergrosston": 12,
            "portofshipment": "string",
            "transshipmentport": "string",
            "placeofdelivery": "string",
            "cargopickupaddress": "string",
            "note": "string",
            "isvisible": "0",
            "index": 9
        }
    ]
}

Как я уже говорил, если убрать логику проверки на роль администратора, то всё заработает. Тогда я получаю такой ответ:

    {
        "id": "872e32ac-cbe7-4d7d-8365-b6b1b4505968",
        "audit": {
            "createdBy": "0b429df5-bc7f-4291-ae6f-d928c7df6368",
            "createdOnUtc": "2024-07-19T07:14:44.711343Z",
            "lastModifiedDateOnUtc": null,
            "lastModifiedBy": null
        },
        "typeOfRequest": 1,
        "logisticsProcess": {
            "customsClearance": "string",
            "deliveryConditions": "string",
            "cargoReadinessPeriod": "2024-07-16",
            "deadlineForSubmittingCommercialOffer": "2024-07-16"
        },
        "cargoCharacteristics": {
            "typeOfCargo": "string",
            "typeOfPackaging": "string"
        },
        "characteristicsOfTheContainer": {
            "containerType": "string",
            "placesInContainer": 123,
            "loadingInOneContainerNet": 23,
            "numberOfContainers": 14,
            "weightOfOnePlace": 2,
            "loadingPerContainerGrossTon": 12
        },
        "logisticsHubs": {
            "portOfShipment": "string",
            "transshipmentPort": "string",
            "placeOfDelivery": "string",
            "cargoPickupAddress": "string"
        },
        "note": "string",
        "isVisible": false
    },

Помогите пожалуйста понять, что я делаю не так

Просмотрел много тем по этому вопросу и не нашел ответа.

Стоит ли изучать PHP в 2026-2027 годах?
Стоит ли изучать PHP в 2026-2027 годах?
Привет всем, сегодня я хочу высказать свои соображения по поводу вопроса, который я уже много раз получал в своем сообществе: "Стоит ли изучать PHP в...
Поведение ключевого слова "this" в стрелочной функции в сравнении с нормальной функцией
Поведение ключевого слова "this" в стрелочной функции в сравнении с нормальной функцией
В JavaScript одним из самых запутанных понятий является поведение ключевого слова "this" в стрелочной и обычной функциях.
Приемы CSS-макетирования - floats и Flexbox
Приемы CSS-макетирования - floats и Flexbox
Здравствуйте, друзья-студенты! Готовы совершенствовать свои навыки веб-дизайна? Сегодня в нашем путешествии мы рассмотрим приемы CSS-верстки - в...
Тестирование функциональных ngrx-эффектов в Angular 16 с помощью Jest
В системе управления состояниями ngrx, совместимой с Angular 16, появились функциональные эффекты. Это здорово и делает код определенно легче для...
Концепция локализации и ее применение в приложениях React ⚡️
Концепция локализации и ее применение в приложениях React ⚡️
Локализация - это процесс адаптации приложения к различным языкам и культурным требованиям. Это позволяет пользователям получить опыт, соответствующий...
Пользовательский скаляр GraphQL
Пользовательский скаляр GraphQL
Листовые узлы системы типов GraphQL называются скалярами. Достигнув скалярного типа, невозможно спуститься дальше по иерархии типов. Скалярный тип...
1
0
95
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

SplitOn разбивает данные одной строки на несколько объектов на основе имен столбцов, которые вы в них вводите. Исключение хорошо говорит о том, что происходит.

Причина вашего исключения заключается в том, что у вас нет столбца CreatedBy в опубликованном вами SQL-запросе и отмеченном как correct.

Кроме того, по той же причине, если вы удалите логику с помощью Administrator, она будет работать хорошо, потому что ни в вашем CreatedBy, ни в ваших данных нет столбца splitOn, который вы пытаетесь разделить.

Дело в том, что столбец CreatedBy, CreatedOnUtc, LastModifiedDateOnUtc, LastModifiedBy мне не нужен. Если роль не является администратором, то есть мне не нужен объект аудита, для которого я установил значение null с помощью этой строки request.IdentityUser.IdentityRoles.Contains("Администратор") ? ноль: тип(Аудит). И поэтому я удаляю часть строки sql

keks01 19.07.2024 10:45

@keks01 но либо я тебя не понимаю, либо ты меня не понял. Как splitOn должен разделить строку, если столбец CreatedBy отсутствует в данных? Если вы хотите это сделать, вам следует подготовить два SQL-запроса. Один содержит CreatedBy, а другой нет.

Bartosz 19.07.2024 10:56

но в этом случае у SplitOn также нет CreatedBy для разделения, это достигается с помощью такого тернарного оператора (request.IdentityUser.IdentityRoles.Contains("Administrator"‌​) ? ",CreatedBy," : ","))

keks01 19.07.2024 11:04

это не имеет никакого смысла. Если сказать, что когда удаляешь, то работает, значит условие каким-то образом выполняется, и он ставит CreatedBy в splitOn. Другого способа сломать его нет.

Bartosz 19.07.2024 11:25

если установить роль «Администратор», все работает нормально. Но если запрос не содержит роль «Администратор», я удаляю часть строки sql, в которой запрашиваются данные аудита, а также удаляю CreatedBy из строки SplitOn. В результате sql-запрос не содержит CreatedBy, CreatedOnUtc, LastModifiedDateOnUtc, LastModifiedBy, то есть данных аудита. SplitOn также не имеет столбца CreatedBy для разделения; строка SplitOn выглядит так: $"Id,TypeOfRequest...

keks01 19.07.2024 11:42

@ keks01, если это правда, боюсь, я не смогу больше помочь тебе по этой теме. Он должен работать.

Bartosz 19.07.2024 12:01

В любом случае спасибо за помощь

keks01 19.07.2024 12:05
Ответ принят как подходящий

Проблема была в массиве Type[]:

new[]
{
  typeof(Guid),
  typeof(Audit),
  typeof(TypeOfRequest),
  typeof(LogisticsProcess),
  typeof(CargoCharacteristics),
  typeof(CharacteristicsOfTheContainer),
  typeof(LogisticsHubs),
  typeof(string),
  typeof(bool),
}

Если роль не администратор, то я удаляю кусок sql-строки, которая запрашивает CreatedBy, CreatedOnUtc, LastModifiedDateOnUtc, LastModifiedBy, иными словами объект Audit. Соответственно, sql-запрос возвращает данные без данных Audit, но у Type[] есть typeof(Audit) и его нужно заполнить. И заполнять нечего.

new[]
{
  typeof(Guid),
  typeof(Audit),
  ....
}

Это и стало причиной ошибки. Рефакторинг кода ниже:

public async Task<Result<IReadOnlyList<GetTransportationRequestResponse>>> Handle(
    GetTransportationRequestQuery request, CancellationToken cancellationToken)
{
    var isRoleAdministrator = request.IdentityUser.IdentityRoles.Contains("Administrator");

    var sqlString =
           """
           SELECT
               a.id AS Id,
               a.created_by AS CreatedBy, 
               a.created_on_utc AS CreatedOnUtc,
               a.last_modified_date_on_utc AS LastModifiedDateOnUtc,
               a.last_modified_by AS LastModifiedBy,
               a.type_of_request AS TypeOfRequest,
               a.customs_clearance AS CustomsClearance,
               a.delivery_conditions AS DeliveryConditions,
               a.cargo_readiness_period AS CargoReadinessPeriod,
               a.deadline_for_submitting_commercial_offer AS DeadlineForSubmittingCommercialOffer,
               a.type_of_cargo AS TypeOfCargo,
               a.type_of_packaging AS TypeOfPackaging,
               a.container_type AS ContainerType,
               a.places_in_container AS PlacesInContainer,
               a.loading_in_one_container_net AS LoadingInOneContainerNeT,
               a.number_of_containers AS NumberOfContainers,
               a.weight_of_one_place AS WeightOfOnePlace,
               a.loading_per_container_gross_ton AS LoadingPerContainerGrossTon,  
               a.port_of_shipment AS PortOfShipment,
               a.transshipment_port AS TransshipmentPort,
               a.place_of_delivery AS PlaceOfDelivery,
               a.cargo_pickup_address AS CargoPickupAddress,
               a.note AS Note,
               a.is_visible AS IsVisible,
               a.index AS Index
           FROM transportation_request AS a
           """;

    List<Type> getTransportationRequestResponseTypes = 
    [
        typeof(Guid),
        typeof(Audit),
        typeof(TypeOfRequest),
        typeof(LogisticsProcess),
        typeof(CargoCharacteristics),
        typeof(CharacteristicsOfTheContainer),
        typeof(LogisticsHubs),
        typeof(string),
        typeof(bool)
    ];

    if (!isRoleAdministrator)
    {
        var firstIndexOfWord = IndexOfFirstLetter(sqlString, "a.created_by");
        var lastIndexOfWord = IndexOfLastLetter(sqlString, "LastModifiedBy,\r\n    ");

        sqlString = sqlString.Remove(firstIndexOfWord, lastIndexOfWord - firstIndexOfWord);

        getTransportationRequestResponseTypes.RemoveAt(1); //1 is an index of Audit type
    }

    using var connection = _sqlConnectionFactory.CreateConnection();

    var transportationRequestResponse = await connection.QueryAsync<GetTransportationRequestResponse>(
        sqlString,
        getTransportationRequestResponseTypes.ToArray(),
        objects => 
        {
            Guid id = (Guid)objects[0];
            Audit? audit = isRoleAdministrator ? (Audit)objects[1] : null;
            TypeOfRequest typeOfRequest = (TypeOfRequest)objects[^7];
            LogisticsProcess logisticsProcess = (LogisticsProcess)objects[^6];
            CargoCharacteristics cargoCharacteristics = (CargoCharacteristics)objects[^5];
            CharacteristicsOfTheContainer characteristicsOfTheContainer = (CharacteristicsOfTheContainer)objects[^4];
            LogisticsHubs logisticsHubs = (LogisticsHubs)objects[^3];
            string note = (string)objects[^2];
            bool isVisible = (bool)objects[^1];

            GetTransportationRequestResponse getTransportationRequestResponse = new(
                id,
                audit,
                typeOfRequest,
                logisticsProcess,
                cargoCharacteristics,
                characteristicsOfTheContainer,
                logisticsHubs,
                note,
                isVisible);

            return getTransportationRequestResponse;
        },

        splitOn: $"Id{(isRoleAdministrator ? ",CreatedBy," : ",")}TypeOfRequest,CustomsClearance,TypeOfCargo,ContainerType,PortOfShipment,Note,IsVisible");


    return transportationRequestResponse.ToList();
}

Я просто составил List и заполнил его на основе isRoleAdministrator и заполнил нужными типами.

Другие вопросы по теме