SQLKata простой запрос SELECT, возвращающий «недопустимое имя объекта» для допустимой таблицы? - PullRequest
0 голосов
/ 21 декабря 2018

Кто-нибудь использовал библиотеку SqlKata и имел проблемы с выполнением даже простого SELECT * FROM TABLE?Я пробовал как стандартный GET (который создает запрос с таблицей в [], так и GetRaw, который создает запрос без []).

Оба запроса возвращают недопустимое имя объекта для явно доступной таблицы?Мое приложение записывает в журналы следующее:

[Error] SELECT * FROM InSiteStoreInfo
[Error] Invalid object name 'InSiteStoreInfo'.

Пример кода, который я использую, приведен ниже (я также пробовал не-сырую версию Get).

public async Task<APIGatewayProxyResponse> GetQueryKata(APIGatewayProxyRequest request, ILambdaContext context)
    {
        LogLevel environmentLogLevel = (LogLevel)Convert.ToInt32(Environment.GetEnvironmentVariable("LOG_LEVEL"));
        string jsonOutput = null;
        APIGatewayProxyResponse proxyResponse = new APIGatewayProxyResponse(); 

        try
        {
            using (var connection = new SqlConnection(
                await RetrieveParameterStoreValue(ParameterStoreStrings.Database, true, context, environmentLogLevel)))
            {

                var db = new QueryFactory(connection, new SqlServerCompiler());

                // Log the compiled query to the console
                db.Logger = compiled => {
                   CreateCloudWatchLog(compiled.ToString(),context,LogLevel.Error,environmentLogLevel);
                };

                var results = db.Query().FromRaw("InSiteStoreInfo").Get();
                CreateCloudWatchLog(JsonConvert.SerializeObject(results, Formatting.Indented),context, LogLevel.Error,environmentLogLevel);
                jsonOutput = JsonConvert.SerializeObject(results, Formatting.Indented);
            }

            proxyResponse = await BuildResponse(jsonOutput, HttpStatusCode.OK, context, environmentLogLevel);
        }
        catch (Exception ex)
        {
            CreateCloudWatchLog(ex.Message, context, LogLevel.Error, environmentLogLevel);
            proxyResponse = await BuildResponse(ex.Message, HttpStatusCode.BadRequest, context, environmentLogLevel);
        }

        return proxyResponse; 
    }
...