public object AvgValue(string FieldName, string TableName, string Conditions, object DefaultValue, params FieldParam[] Parameters) { object _Value; string SqlSelect = string.Concat("SELECT ", Dp.GetSqlAvg(), "(", FieldName, ") FROM ", TableName); if (Conditions.Length > 0) { SqlSelect = string.Concat(SqlSelect, " WHERE ", Conditions); } return(TryFindValue(SqlSelect, out _Value, Parameters) ? _Value : DefaultValue); }
public bool TryFindAvgValue <TEntity>(string FieldName, string Conditions, out object Value, params FieldParam[] Parameters) where TEntity : BaseEntity { TableDef td = MetaData.GetTableDef(typeof(TEntity)); DataPersistance Dp = td.GetDataPersistance(this.Dp); Dp.ValidateTableDef(td); string SqlSelect = string.Concat("SELECT ", Dp.GetSqlAvg(), "(", GetFieldName(td, FieldName), ") FROM ", td.GetSqlHeaderView(Dp)); if (Conditions.Length > 0) { SqlSelect = string.Concat(SqlSelect, " WHERE ", Conditions); } return(Dp.Find.TryFindValue(SqlSelect, out Value, Parameters)); }