Esempio n. 1
0
        private void EnsureTable(Type type)
        {
            var tableName = ConventionReader.GetTableName(type);

            if (!_tables.ContainsKey(tableName))
            {
                _tables[tableName] = new ResultSet();
            }
        }
Esempio n. 2
0
        public void EnsureSubQuery(string alias, Type type)
        {
            var tableName = _conventionReader.GetTableName(type);

            if (!HasSubQuery(tableName, alias))
            {
                CreateSubQuery(alias, type);
            }
        }
Esempio n. 3
0
        public void Delete <T>(T instance)
        {
            var tableName = _conventionReader.GetTableName <T>();

            var primaryKeyColumnName = _conventionReader.GetPrimaryKeyColumnName <T>();
            var primaryKeyValue      = _conventionReader.GetPrimaryKeyValue(instance);

            var constraintExpression = QueryExpression.Create(new EqualsExpression(primaryKeyColumnName, primaryKeyValue));

            var command = _sqlGenerator.CreateDeleteCommand(tableName, constraintExpression);

            _dbCommandExecutor.ExecuteNonQuery(command, ConnectionString);
        }
Esempio n. 4
0
        public int Count <T>(QueryExpression queryExpression)
        {
            var tableName = _conventionReader.GetTableName <T>();
            var command   = _sqlGenerator.CreateCountCommand(tableName, queryExpression.Translate(_conventionReader));

            return(_dbCommandExecutor.ExecuteScalar <int>(command, ConnectionString));
        }
Esempio n. 5
0
        public static AliasedSqlSubQuery Create(string alias, Type type, IConventionReader conventionReader)
        {
            var subQuery = new AliasedSqlSubQuery()
            {
                Alias     = alias,
                TableName = conventionReader.GetTableName(type),
                AllSelectableColumnNames = conventionReader.GetSelectableColumNames(type).ToList(),
                PrimaryKeyColumnName     = conventionReader.TryGetPrimaryKeyColumnName(type)
            };

            return(subQuery);
        }
Esempio n. 6
0
        private IEnumerable <TCommand> CreateInsertCommands <TEntity, TCommand>(IEnumerable <TEntity> entities, Func <string, IDictionary <string, object>, TCommand> f)
        {
            var commands = new List <TCommand>();

            foreach (var entity in entities)
            {
                var columnValues = _conventionReader.GetColumnValuesForInsertOrUpdate(entity);
                var tableName    = _conventionReader.GetTableName <TEntity>();

                var command = f(tableName, columnValues);

                commands.Add(command);
            }

            return(commands);
        }
Esempio n. 7
0
 public string GetTableIdentifier(IConventionReader conventionReader)
 {
     return _alias ?? conventionReader.GetTableName(_type);
 }
Esempio n. 8
0
 public string GetTableIdentifier(IConventionReader conventionReader)
 {
     return(_alias ?? conventionReader.GetTableName(_type));
 }