<commit_before>﻿using System;
using System.Collections.Generic;

namespace ZenOh_ActiveRecord
{

    public class SQLBuilder
    {
        private string Condition;
        private Type Entity;
        private string Schema;
        private string Script;

        public SQLBuilder(Type Entity, string Schema)
        {
            this.Entity = Entity;
            this.Schema = Schema;
            this.Condition = "";
        }
        
        public SQLBuilder Select()
        {
            this.Script = "Select * from " + this.Schema + "." + Entity.Name;
            return this;
        }

        public SQLBuilder Delete()
        {
            this.Script = "Delete from " + this.Schema + "." + Entity.Name;
            return this;
        }

        public override string ToString()
        {
            return this.Script + " Where " + this.Condition;
        }

        public SQLBuilder Eq(string Field, object value)
        {
            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " = '" + value + "')";
            else
                this.Condition = this.Condition + " and ( " + Field + " = '" + value + "')";

            return this;
        }

        public SQLBuilder Not(string Field, object value)
        {
            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " <> '" + value + "')";
            else
                this.Condition = this.Condition + " and ( " + Field + " <> '" + value + "')";

            return this;
        }

        public SQLBuilder In(string Field, List<Object> Values)
        {
            string ConditionIn = "(";

            foreach (var i in Values)
            {
                if (ConditionIn == string.Empty)
                    ConditionIn = "'" +  i.ToString() + "'";
                else
                    ConditionIn = ConditionIn + ", " + "'" + i.ToString() + "'";

            }

            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " in " + ConditionIn + ")";
            else
                this.Condition = this.Condition + " and ( " + Field + " in " + ConditionIn + ")";

            return this;
        }

        public SQLBuilder NotIn(string Field, List<object> Values)
        {
            string ConditionIn = "(";

            foreach (var i in Values)
            {
                if (ConditionIn == string.Empty)
                    ConditionIn = i.ToString();
                else
                    ConditionIn = ConditionIn + ", " + i.ToString();

            }

            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " not in " + ConditionIn + ")";
            else
                this.Condition = this.Condition + " and ( " + Field + " not in " + ConditionIn + ")";

            return this;
        }

        public SQLBuilder Betwenn(string Field, object Start, object End)
        {
            if (Condition == string.Empty)
                Condition = " ( " + Field + " between '" + Start + "' and '" + End + "')";
            else
                Condition = Condition + " and ( " + Field + " between '" + Start + "' and '" + End + "')";

            return this;
        }
    }
}<commit_msg>Like SQLBuilder<commit_after>﻿using System;
using System.Collections.Generic;

namespace ZenOh_ActiveRecord
{

    public class SQLBuilder
    {
        private string Condition;
        private Type Entity;
        private string Schema;
        private string Script;

        public SQLBuilder(Type Entity, string Schema)
        {
            this.Entity = Entity;
            this.Schema = Schema;
            this.Condition = "";
        }
        
        public SQLBuilder Select()
        {
            this.Script = "Select * from " + this.Schema + "." + Entity.Name;
            return this;
        }

        public SQLBuilder Delete()
        {
            this.Script = "Delete from " + this.Schema + "." + Entity.Name;
            return this;
        }

        public override string ToString()
        {
            return this.Script + " Where " + this.Condition;
        }

        public SQLBuilder Eq(string Field, object value)
        {
            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " = '" + value + "')";
            else
                this.Condition = this.Condition + " and ( " + Field + " = '" + value + "')";

            return this;
        }

        public SQLBuilder Not(string Field, object value)
        {
            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " <> '" + value + "')";
            else
                this.Condition = this.Condition + " and ( " + Field + " <> '" + value + "')";

            return this;
        }

        public SQLBuilder In(string Field, List<Object> Values)
        {
            string ConditionIn = "(";

            foreach (var i in Values)
            {
                if (ConditionIn == string.Empty)
                    ConditionIn = "'" +  i.ToString() + "'";
                else
                    ConditionIn = ConditionIn + ", " + "'" + i.ToString() + "'";

            }

            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " in " + ConditionIn + ")";
            else
                this.Condition = this.Condition + " and ( " + Field + " in " + ConditionIn + ")";

            return this;
        }

        public SQLBuilder NotIn(string Field, List<object> Values)
        {
            string ConditionIn = "(";

            foreach (var i in Values)
            {
                if (ConditionIn == string.Empty)
                    ConditionIn = i.ToString();
                else
                    ConditionIn = ConditionIn + ", " + i.ToString();

            }

            if (this.Condition == string.Empty)
                this.Condition = "( " + Field + " not in " + ConditionIn + ")";
            else
                this.Condition = this.Condition + " and ( " + Field + " not in " + ConditionIn + ")";

            return this;
        }

        public SQLBuilder Betwenn(string Field, object Start, object End)
        {
            if (Condition == string.Empty)
                Condition = " ( " + Field + " between '" + Start + "' and '" + End + "')";
            else
                Condition = Condition + " and ( " + Field + " between '" + Start + "' and '" + End + "')";

            return this;
        }

        public SQLBuilder Like(string Field, string value)
        {
            if (Condition == string.Empty)
               Condition = "( Upper(" + Field + ") Like '" + value.ToUpper() + "')";
            else
              Condition = Condition + " and ( Upper(" + Field + ") Like '" + value.ToUpper() + "')";

            return this;

        }

    }
}
{'fraction_non_alphanumeric': 0.12525369672368802, 'fraction_numerical': 0.0, 'mean_word_length': 1.320551631348806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5006392', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1688, 'n_words': 435}