private bool ShouldUpdateColumn <TDbEntity, TId>( ref DbValue <TId> column, TId value, ref IDbEntityRef <TDbEntity> dbEntityRef, Func <long> getValueAsLongOrZero) where TDbEntity : DbEntity { if (EqualityComparer <TId> .Default.Equals(column.Entity, value)) { return(false); } if (!_allowSettingColumns) { var writeDb = _db as WriteDb; if (writeDb != null && writeDb.Settings.ReturnPreviouslyLoadedEntity_Obsolete) { if (column.ValueWasAssigned() || (dbEntityRef != null && dbEntityRef.HasAssignedValue)) { // we do not want to modify updated entities by returning them again with a query return(false); } } throw new InvalidOperationException( "Review your query. It smells wrong! Most probably you used UnionDb() with queries that have different columns."); } if (dbEntityRef != null) { if (dbEntityRef is DbEntityRefCached <TDbEntity> ) { dbEntityRef = GlobalDbConfiguration.GetConfigurationOrEmpty(GetType()).CacheService.GetDbEntityRefCached <TDbEntity>((int)getValueAsLongOrZero()); } else { dbEntityRef.ResetValue(); } } return(true); }