コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }