public T GetSingle <T>(string field, object value) where T : IOrmGenerated { using (var rep = new SqlRepository(_Configuration, _Logger)) return(rep.ExecuteSqlSingle <T>($"WHERE [{field}] = @{field}", new List <System.Data.SqlClient.SqlParameter> { new System.Data.SqlClient.SqlParameter($"@{field}", value) })); }
public T GetSingle <T>(string field, object value, DataConditional conditional = DataConditional.EqualTo) where T : IOrmGenerated { using (var rep = new SqlRepository(_Configuration, _Logger)) { Sanitise(field); if (conditional == DataConditional.NotNull || conditional == DataConditional.IsNull) { var sql = $"WHERE [{field}] {conditional.GetDataConditional()}"; var ret = rep.ExecuteSqlSingle <T>(sql, new List <SqlParameter>()); return(ret); } else { var sql = $"WHERE [{field}] {conditional.GetDataConditional()} @{field}"; var ret = rep.ExecuteSqlSingle <T>(sql, new List <SqlParameter> { new SqlParameter($"@{field}", value) }); return(ret); } } }