コード例 #1
0
        public void BuildingClauseWhenSelectIsNotDefined()
        {
            var data   = new Dictionary <string, string>();
            var result = SelectClause.Build(new ODataOptions <Model>(data));

            result.Should().Be("SELECT * FROM");
        }
コード例 #2
0
        public override IEnumerable <TResult> Convert(DbCommandResult commandResult)
        {
            if (selectClause.ConvertExpression == null)
            {
                selectClause.Build(ServiceProvider.GetRequiredService <DbCommandBuilder>(), ServiceProvider);
            }

            return(selectClause.ConvertExpression.Convert(commandResult, true));
        }
コード例 #3
0
        public void BuildingClauseWhenCommandDoesNotSpecifyColumns()
        {
            var data = new Dictionary <string, string> {
                ["$select"] = "Id,Name"
            };

            var result = SelectClause.Build("SELECT FROM Table", new ODataOptions <Model>(data));

            result.Should().Be("SELECT [Id], [Name] FROM Table");
        }
コード例 #4
0
        public void BuildingClauseWhenTopIsDefined()
        {
            var data = new Dictionary <string, string> {
                ["$top"] = "20"
            };

            var result = SelectClause.Build(new ODataOptions <Model>(data));

            result.Should().Be("SELECT TOP(20) * FROM");
        }
コード例 #5
0
        public void BuildingClauseWhenSelectIsDefined()
        {
            var data = new Dictionary <string, string> {
                ["$select"] = "Id,Name"
            };

            var result = SelectClause.Build(new ODataOptions <Model>(data));

            result.Should().Be("SELECT [Id], [Name] FROM");
        }
コード例 #6
0
        public void BuildingClauseWhenSelectContainsWildcard()
        {
            var data = new Dictionary <string, string> {
                ["$select"] = "*,Name"
            };

            var result = SelectClause.Build(new ODataOptions <Model>(data));

            result.Should().Be("SELECT * FROM");
        }
コード例 #7
0
        public void BuildingClauseWhenCommandSpecifiesTop()
        {
            var data = new Dictionary <string, string> {
                ["$top"] = "20"
            };

            var result = SelectClause.Build("SELECT TOP(40) FROM", new ODataOptions <Model>(data));

            result.Should().Be("SELECT TOP(40) * FROM");
        }
コード例 #8
0
        public void BuildingClauseWhenCommandSpecifiesColumns()
        {
            var data = new Dictionary <string, string> {
                ["$select"] = "Id"
            };

            var result = SelectClause.Build("SELECT Name FROM Table", new ODataOptions <Model>(data));

            result.Should().Be("SELECT Name FROM Table");
        }
コード例 #9
0
        public override IEnumerable <TResult> Convert(DbCommandResult commandResult)
        {
            if (genericSelectClause == null)
            {
                throw new InvalidOperationException();
            }

            var environmentOption = ServiceProvider.GetRequiredService <EnvironmentOption>();

            if (genericSelectClause.ConvertExpression == null)
            {
                genericSelectClause.Build(ServiceProvider.GetRequiredService <DbCommandBuilder>(), ServiceProvider);
            }

            return(genericSelectClause.ConvertExpression.Convert(commandResult, !environmentOption.IsSubQuery));
        }