Esempio n. 1
0
        public SqlQueryContext Build(SqlQueryContext query, IHaveSelectionSet context, string alias)
        {
            query.Select($"{alias}.Id");
            query.SplitOn <City>("Id");

            foreach (var field in context.GetSelectedFields())
            {
                switch (field.Key.ToLower())
                {
                case "name":
                    query.Select($"{alias}.Name");
                    break;

                case "zipcode":
                    query.Select($"{alias}.ZipCode");
                    break;

                case "country":
                    var countryAlias = $"{alias}Country";
                    query.InnerJoin($"Countries {countryAlias} on {alias}.CountryId = {countryAlias}.Id");
                    query = new CountryQuery().Build(query, field.Value, countryAlias);
                    break;
                }
            }

            return(query);
        }
Esempio n. 2
0
        public SqlQueryContext Build(SqlQueryContext query, IHaveSelectionSet context, string alias)
        {
            query.Select($"{alias}.Id");
            query.SplitOn <Person>("Id");

            foreach (var field in context.GetSelectedFields())
            {
                switch (field.Key.ToLower())
                {
                case "firstname":
                    query.Select($"{alias}.FirstName");
                    break;

                case "lastname":
                    query.Select($"{alias}.LastName");
                    break;

                case "address":
                    var addressAlias = $"{alias}Address";
                    query.InnerJoin($"Addresses {addressAlias} on {alias}.AddressId = {addressAlias}.Id");
                    query = new AddressQuery().Build(query, field.Value, addressAlias);
                    break;
                }
            }

            return(query);
        }
Esempio n. 3
0
        public SqlQueryContext Build(SqlQueryContext query, IHaveSelectionSet context, string alias)
        {
            query.Select($"{alias}.Id");
            query.SplitOn <Address>("Id");

            foreach (var field in context.GetSelectedFields())
            {
                switch (field.Key.ToLower())
                {
                case "street":
                    query.Select($"{alias}.Street");
                    break;

                case "city":
                    var cityAlias = $"{alias}City";
                    query.InnerJoin($"Cities {cityAlias} on {alias}.CityId = {cityAlias}.Id");
                    query = new CityQuery().Build(query, field.Value, cityAlias);
                    break;
                }
            }

            return(query);
        }