public override DbExpression Visit(DbScanExpression expression) { var table = (EntityType)expression.Target.ElementType; //only need to check for IsDeleted column //IsDeleted and IsNew always go side by side in BaseEntity if (table.Properties.All(p => p.Name != IsDeletedColumnName)) { return(base.Visit(expression)); } var binding = expression.Bind(); //return binding.Filter( // binding.VariableType // .Variable(binding.VariableName) // .Property(IsDeletedColumnName) // .Equal(DbExpression.FromBoolean(false))); var filter = DbExpressionBuilder.And( binding.VariableType .Variable(binding.VariableName) .Property(IsDeletedColumnName) .Equal(DbExpression.FromBoolean(false)), binding.VariableType .Variable(binding.VariableName) .Property(IsNewColumnName) .Equal(DbExpression.FromBoolean(false))); return(binding.Filter(filter)); }
public override DbExpression Visit(DbScanExpression expression) { //Check if POCO has system Status flag if (expression.Target.ElementType.Members.All(x => x.Name != "SystemStatus")) { return(base.Visit(expression)); } //**** Copied this from the EF team: https://github.com/rowanmiller/Demo-TechEd2014 **** // Just because the entity has the soft delete annotation doesn't mean that // this particular table has the column. This occurs in situation like TPT // inheritance mapping and entity splitting where one type maps to multiple // tables. // We only apply the filter if the column is actually present in this table. // If not, then the query is going to be joining to the table that does have // the column anyway, so the filter will still be applied. var table = (EntityType)expression.Target.ElementType; if (table.Properties.Any(p => p.Name == "Status")) { var binding = expression.Bind(); return (binding.Filter( binding.VariableType.Variable(binding.VariableName) .Property("Status") .NotEqual(DbExpression.FromInt32((int)SystemStatus.Deleted)))); } return(base.Visit(expression)); }
public override DbExpression Visit(DbScanExpression expression) { if (!expression.Target.ElementType.MetadataProperties.Any(mp => mp.Name.EndsWith("customannotation:" + AbpEfConsts.SoftDeleteCustomAnnotationName))) { return base.Visit(expression); } var binding = expression.Bind(); return binding .Filter(binding.VariableType.Variable(binding.VariableName) .Property("IsDeleted")//TODO: User may want to bind to another column name. It's better to use actual database column name .Equal(DbExpression.FromBoolean(false))); }
public override DbExpression Visit(DbScanExpression expression) { if (!expression.Target.ElementType.MetadataProperties.Any(mp => mp.Name.EndsWith("customannotation:" + AbpEfConsts.SoftDeleteCustomAnnotationName))) { return(base.Visit(expression)); } var binding = expression.Bind(); return(binding .Filter(binding.VariableType.Variable(binding.VariableName) .Property("IsDeleted")//TODO: User may want to bind to another column name. It's better to use actual database column name .Equal(DbExpression.FromBoolean(false)))); }
public override DbExpression Visit(DbScanExpression expression) { if (this.FilterValue > 0) { // Get the current expression var dbExpression = base.Visit(expression); var binding = expression.Bind(); return(binding.Filter( binding.VariableType .Variable(binding.VariableName) .Property("FilterFieldName") .Equal(DbExpression.FromInt32(this.FilterValue)))); } return(base.Visit(expression)); }
public override DbExpression Visit(DbScanExpression expression) { var table = (EntityType)expression.Target.ElementType; if (table.Properties.All(p => p.Name != DeletedColumnName)) { return(base.Visit(expression)); } var binding = expression.Bind(); return(binding.Filter( binding.VariableType .Variable(binding.VariableName) .Property(DeletedColumnName).IsNull())); }
public override DbExpression Visit(DbScanExpression expression) { var table = (EntityType)expression.Target.ElementType; if (table.Properties.All(p => p.Name != IsDeletedColumnName) || this.EnableSoftDeleteQuery) { return(base.Visit(expression)); } var binding = expression.Bind(); return(binding.Filter( binding.VariableType .Variable(binding.VariableName) .Property(IsDeletedColumnName) .NotEqual(DbExpression.FromBoolean(true)))); }
public override DbExpression Visit(DbScanExpression expression) { const string column = "IsActive"; var table = (EntityType)expression.Target.ElementType; if (!table.Properties.Any(p => p.Name == column)) return base.Visit(expression); var binding = expression.Bind(); return binding.Filter( binding.VariableType.Variable(binding.VariableName) .Property(column) .Equal(DbExpression.FromBoolean(true))); }
public override DbExpression Visit(DbScanExpression expression) { var columnName = SoftDeleteAttribute.GetSoftDeleteColumnName(expression.Target.ElementType); var entityType = (EntityType)expression.Target.ElementType; if (columnName == null || entityType.Properties.All(p => p.Name != columnName)) { return(base.Visit(expression)); } var binding = expression.Bind(); return(binding.Filter( binding.VariableType .Variable(binding.VariableName) .Property(columnName) .NotEqual(DbExpression.FromBoolean(true)))); }
public override DbExpression Visit(DbScanExpression expression) { const string column = "IsActive"; var table = (EntityType)expression.Target.ElementType; if (!table.Properties.Any(p => p.Name == column)) { return(base.Visit(expression)); } var binding = expression.Bind(); return (binding.Filter( binding.VariableType.Variable(binding.VariableName) .Property(column) .Equal(DbExpression.FromBoolean(true)))); }
public override DbExpression Visit(DbScanExpression expression) { var column = ColumnAnnotationAttribute.GetColumnName <TrackDeletedBitAttribute>(expression.Target.ElementType); // var column = TrackDeletedBitAttribute.GetColumnName(expression.Target.ElementType); if (column != null) { var binding = expression.Bind(); return(binding .Filter(binding.VariableType.Variable(binding.VariableName) .Property(column) .NotEqual(DbExpression.FromBoolean(true)) .Or(binding.VariableType.Variable(binding.VariableName) .Property(column).IsNull()))); } else { return(base.Visit(expression)); } }
public override DbExpression Visit(DbScanExpression expression) { var column = SoftDeleteAttribute.GetSoftDeleteColumnName(expression.Target.ElementType); if (column != null) { var table = (EntityType)expression.Target.ElementType; if (table.Properties.Any(p => p.Name == column)) { var binding = expression.Bind(); var filter = binding .VariableType .Variable(binding.VariableName) .Property(column) .NotEqual(DbExpression.FromBoolean(true)); return binding.Filter(filter); } } return base.Visit(expression); }
public override DbExpression Visit(DbScanExpression expression) { var table = (EntityType)expression.Target.ElementType; if (table.Properties.All(p => p.Name != IsDeletedColumnName)) { return(base.Visit(expression)); } DbExpression newConditionExpression = null; var binding = expression.Bind(); if (table.Properties.Any(p => p.Name == IsDeletedColumnName)) { var param = DbExpression.FromBoolean(false); var columnProperty = DbExpressionBuilder.Property(DbExpressionBuilder.Variable(binding.VariableType, binding.VariableName), IsDeletedColumnName); if ((columnProperty.ResultType.EdmType.FullName == "Edm.Boolean") && param.ResultType.EdmType.FullName.StartsWith("Oracle", StringComparison.CurrentCultureIgnoreCase) && (param.ResultType.EdmType.Name == "number")) { newConditionExpression = DbExpressionBuilder.Equal(DbExpressionBuilder.CastTo(columnProperty, param.ResultType), param); } else { newConditionExpression = DbExpressionBuilder.Equal(columnProperty, param); } } return(DbExpressionBuilder.Filter(binding, newConditionExpression)); //return binding.Filter( // binding.VariableType // .Variable(binding.VariableName) // .Property(IsDeletedColumnName) // .Equal(DbExpression.FromBoolean(false))); }