Пример #1
0
 public static SqlQuery ToSql(this ConditionExp c, SqlQuery query)
 {
     var fieldName = GetName((dynamic) c.Field);
     var pname = $"@{query.Params.Count + 1}";
     query.Sql = $"{query.Sql} {fieldName} {c.Op} {pname}";
     query.Params.Add(pname,c.Value);
     return query;
 }
Пример #2
0
        public static SqlQuery From(TableExp exp)
        {
            var query = new SqlQuery();
            var whereQuery = exp.Exp.ToSql(query);
            var select = $"SELECT * FROM  {exp.Name}";
            var where = exp.Exp.Children.Count > 0
                ? $"WHERE {whereQuery.Sql}"
                : "";
            var sql = $"{select} {where}";

            return new SqlQuery
            {
                Sql = sql,
                Params = whereQuery.Params
            };
        }
Пример #3
0
        public static SqlQuery ToSql(this GroupExp group, SqlQuery query)
        {
            var childrenQuery = new SqlQuery
            {
                Params = query.Params
            };

            childrenQuery =
                group
                    .Children
                    .Aggregate(
                        childrenQuery,
                        (current, child) => ToSql(((dynamic)child),current));

            query.Sql = $"AND ({childrenQuery.Sql}) ";
            return query;
        }
Пример #4
0
 public static SqlQuery ToSql(this Exp c, SqlQuery query)
 {
     return query;
 }