38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
namespace LaaProduction.Cordonel.Models
|
|
{
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
public class WhereQuery : IEnumerable<KeyValuePair<string, object>>
|
|
{
|
|
private string sql = string.Empty;
|
|
private IDictionary<string, object> parameters
|
|
= new Dictionary<string, object>();
|
|
|
|
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
|
=> this.parameters.GetEnumerator();
|
|
|
|
public override string ToString()
|
|
=> this.sql;
|
|
|
|
internal void And(string column, string name, object value)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(this.sql))
|
|
{
|
|
this.sql = " WHERE ";
|
|
}
|
|
else
|
|
{
|
|
this.sql += $"{Environment.NewLine} AND ";
|
|
}
|
|
|
|
this.sql += $"{column} = @{name}";
|
|
this.parameters[name] = value;
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
=> this.GetEnumerator();
|
|
}
|
|
}
|