Exemple #1
0
        private void SetQueryContext(SimpleQuery query)
        {
            _query = query;
            var selectClause = _query.Clauses.OfType <SelectClause>().SingleOrDefault();

            if (selectClause != null)
            {
                _columns = selectClause.Columns.ToArray();
            }
            else
            {
                _columns = new SimpleReference[0];
            }

            _whereCriteria = _query.Clauses.OfType <WhereClause>().Aggregate(SimpleExpression.Empty,
                                                                             (seed, where) => seed && where.Criteria);
            _havingCriteria = _query.Clauses.OfType <HavingClause>().Aggregate(SimpleExpression.Empty,
                                                                               (seed, having) => seed && having.Criteria);

            _tableName = ObjectName.Parse(query.TableName.Split('.').Last());
            _table     = _schema.FindTable(_tableName);
            _commandBuilder.SetText(GetSelectClause(_tableName));
        }
Exemple #2
0
        public IEnumerable <ResultSet> Execute(string functionName, IDictionary <string, object> parameters)
        {
            var executor = _executors.GetOrAdd(functionName, f => _connectionProvider.GetProcedureExecutor(this, ObjectName.Parse(f)));

            return(executor.Execute(parameters));
        }
Exemple #3
0
        private CommandTemplate GetCommandTemplate(string tableName, SimpleExpression criteria)
        {
            var tableCommandCache = _commandCaches.GetOrAdd(tableName,
                                                            _ => new ConcurrentDictionary <string, CommandTemplate>());

            var hash = new ExpressionHasher().Format(criteria);

            return(tableCommandCache.GetOrAdd(hash,
                                              _ =>
                                              new FindHelper(_adapter.GetSchema())
                                              .GetFindByCommand(ObjectName.Parse(tableName), criteria)
                                              .GetCommandTemplate(_adapter.GetSchema().FindTable(ObjectName.Parse(tableName)))));
        }
Exemple #4
0
        public IEnumerable <IDictionary <string, object> > Find(string tableName, SimpleExpression criteria)
        {
            if (criteria == null)
            {
                return(FindAll(ObjectName.Parse(tableName)));
            }

            var commandBuilder = new FindHelper(_adapter.GetSchema()).GetFindByCommand(ObjectName.Parse(tableName), criteria);

            return(ExecuteQuery(commandBuilder));
        }