setID method

Object? setID(
  1. Object? id
)

Sets the entity id and returns the current id. If the ID is changing the previous loaded entity instance is disposed.

Implementation

Object? setID(Object? id) {
  if (id == null) {
    _id = null;
    _entity = null;
    _entityTime = null;
  } else if (id != _id) {
    var prevID = _getEntityID(_entity);

    _id = id;

    if (id != prevID) {
      _entity = null;
      _entityTime = null;
    }
  }

  return _id;
}