public bool TryBuild(ISqlTranslator translator, out string comparison)
        {
            comparison = "";
            string val1 = _first(translator);
            string val2 = _second(translator);

            if (new[] { val1, val2, _operator }.Any(string.IsNullOrEmpty))
            {
                return(false);
            }

            comparison = WrapWithParentheses($"{WrapWithParentheses(val1)} {_operator} {WrapWithParentheses(val2)}");
            return(true);
        }
Exemplo n.º 2
0
        public bool TryBuild(ISqlTranslator translator, out string comparison)
        {
            comparison = string.Empty;

            if (
                !_first(translator, out string str1) ||
                !_second(translator, out string str2) ||
                string.IsNullOrEmpty(_operator))
            {
                return(false);
            }

            comparison = WrapWithParentheses($"{WrapWithParentheses(str1)} {_operator} {WrapWithParentheses(str2)}");
            return(true);
        }
Exemplo n.º 3
0
        public bool TryBuild(ISqlTranslator translator, out string selectClause)
        {
            selectClause = "";
            if (translator.HasError)
            {
                return(false);
            }

            selectClause = CreateClause(translator);
            if (string.IsNullOrEmpty(selectClause))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public bool TryBuild(ISqlTranslator translator, out string whereClause)
        {
            whereClause = string.Empty;
            if (translator.HasError)
            {
                return(false);
            }

            whereClause = _whereExpression(translator);
            if (string.IsNullOrEmpty(whereClause))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
 protected abstract string CreateClause(ISqlTranslator translator);
Exemplo n.º 6
0
 protected override string CreateClause(ISqlTranslator translator) => CreateClause(_selectExpression(translator));
Exemplo n.º 7
0
 public SelectQueryBuilder(ISqlTranslator translator, Func <IWhereBuilderFactory> createWhereBuilderFactory, Func <ICompare> compareFactory)
 {
     this._translator = translator;
     this._createWhereBuilderFactory = createWhereBuilderFactory;
     this._compareFactory            = compareFactory;
 }
Exemplo n.º 8
0
 public InsertQueryBuilder(ISqlTranslator translator)
 {
     _translator = translator;
 }
Exemplo n.º 9
0
 public UpdateQueryBuilder(ISqlTranslator translator, Func <IWhereBuilderFactory> createWhereBuilderFactory, Func <ICompare> compareFactory)
 {
     _translator = translator;
     _createWhereBuilderFactory = createWhereBuilderFactory;
     _compareFactory            = compareFactory;
 }
Exemplo n.º 10
0
 public SqlRepository(IConfiguration config, ISqlTranslator <TData> sqlTranslator, IMethodLookup methodLookup)
 {
     _connectionString = config.GetConnectionString("DefaultConnection");
     _sqlTranslator    = sqlTranslator;
     _sqlMethodLookup  = methodLookup;
 }