示例#1
0
        public EntityInputKeysExtractDelta(Process process, Entity entity, AbstractConnection connection)
            : base(connection)
        {
            _entity    = entity;
            _fields    = _entity.PrimaryKey.WithInput().Aliases().ToArray();
            _length    = _fields.Length;
            EntityName = entity.Name;

            _entity.CheckForChanges(process, connection);

            if (!_entity.HasRows)
            {
                Debug("No data detected in {0}.", _entity.Alias);
            }

            if (_entity.BeginAndEndAreEqual())
            {
                Debug("No changes detected in {0}.", _entity.Alias);
            }

            var keyQuery = _entity.CanDetectChanges(connection.IsDatabase)
                ? connection.KeyQuery(_entity)
                : connection.KeyAllQuery(_entity);

            var sql = _entity.HasRange ?
                      connection.KeyRangeQuery(_entity) :
                      keyQuery;

            Debug(sql);
            _sql = sql;
        }