Beispiel #1
0
        public SqlStatement GetCrudSqlForSingleRecord(DbTableInfo table, EntityRecord record)
        {
            var          cacheKey = SqlCacheKeyBuilder.BuildCrudKey(record.Status, record.EntityInfo.Name, record.MaskMembersChanged);
            SqlStatement sql      = _sqlCache.Lookup(cacheKey);

            if (sql != null)
            {
                return(sql);
            }
            // build it
            switch (record.Status)
            {
            case EntityStatus.New:
                sql = _crudSqlBuilder.BuildCrudInsertOne(table, record);
                break;

            case EntityStatus.Modified:
                sql = _crudSqlBuilder.BuildCrudUpdateOne(table, record);
                break;

            case EntityStatus.Deleting:
                sql = _crudSqlBuilder.BuildCrudDeleteOne(table);
                break;
            }
            _driver.SqlDialect.ReviewSqlStatement(sql, table);
            _sqlCache.Add(cacheKey, sql);
            return(sql);
        }
Beispiel #2
0
        public SqlStatement GetCrudDeleteMany(DbTableInfo table)
        {
            var cacheKey = SqlCacheKeyBuilder.BuildCrudDeleteManyKey(table.Entity.Name);
            var sql      = _sqlCache.Lookup(cacheKey);

            if (sql != null)
            {
                return(sql);
            }
            sql = _crudSqlBuilder.BuildCrudDeleteMany(table);
            _driver.SqlDialect.ReviewSqlStatement(sql, table);
            _sqlCache.Add(cacheKey, sql);
            return(sql);
        }