protected virtual string GenerateSort(DatabaseQuery query) { var parts = new List <string>(); parts.AddRange(query.OrderByParts.Select(p => query.Column(p.Property) + " DESC".OnlyWhen(p.Descending))); var offset = string.Empty; if (query.PageSize > 0) { offset = $" OFFSET {query.PageStartIndex} ROWS FETCH NEXT {query.PageSize} ROWS ONLY"; } return(parts.ToString(", ") + offset); }
public virtual string GenerateWhere(DatabaseQuery query) { var r = new StringBuilder(); if (SoftDeleteAttribute.RequiresSoftdeleteQuery(query.EntityType)) { query.Criteria.Add(new Criterion("IsMarkedSoftDeleted", false)); } r.Append($" WHERE { query.Column("ID")} IS NOT NULL"); foreach (var c in query.Criteria) { r.Append(Generate(query, c).WithPrefix(" AND ")); } return(r.ToString()); }
public override string GenerateWhere(DatabaseQuery query) { var r = new StringBuilder(); if (SoftDeleteAttribute.RequiresSoftdeleteQuery(query.EntityType)) { query.Criteria.Add(new Criterion("IsMarkedSoftDeleted", false)); } r.Append($" WHERE { query.Column("Id")} IS NOT NULL"); var whereGenerator = new PostgreSqlCriterionGenerator(query); var temp = new List <ICriterion>(); foreach (var c in query.Criteria) { if (c.PropertyName == "ID") { temp.Add(c); } } query.Criteria.RemoveAll(x => x.PropertyName == "ID"); foreach (var c in temp) { query.Criteria.Add(new Criterion("Id", c.FilterFunction, c.Value)); } foreach (var c in query.Criteria) { r.Append(whereGenerator.Generate(c).WithPrefix(" AND ")); } return(r.ToString()); }