Files
laatzen/LaaProductionWeb/LaaProductionWeb.Services/Models/Reports/SqlExpression.cs
T
2023-04-27 11:04:12 +02:00

42 lines
1.1 KiB
C#

namespace LaaProductionWeb.Services.Models.Reports
{
using System.Collections.Generic;
public class SqlExpression
{
private readonly ICollection<string> expressions
= new List<string>();
public string Query { get; set; }
public IDictionary<string, object> Parameters { get; set; }
= new Dictionary<string, object>();
internal void Add(string expression)
=> this.expressions.Add(expression);
internal void Add(string expression, string propertyName, object propertyValue)
{
this.Parameters[propertyName] = propertyValue;
this.expressions.Add(expression);
}
internal SqlExpression BuildOrderBy(string delimiter)
{
this.Query = string.Join(delimiter, this.expressions);
return this;
}
internal SqlExpression BuildWhere(string delimiter)
{
this.Query = this.expressions.Count > 0
? string.Join(delimiter, this.expressions)
: "1 = 1";
return this;
}
}
}