Exemplo n.º 1
0
        public object SumValue(string FieldName, string TableName,
                               string Conditions, object DefaultValue,
                               params FieldParam[] Parameters)
        {
            object _Value;
            string SqlSelect = string.Concat("SELECT ",
                                             Dp.GetSqlSum(), "(", FieldName, ") FROM ", TableName);

            if (Conditions.Length > 0)
            {
                SqlSelect = string.Concat(SqlSelect, " WHERE ", Conditions);
            }
            return(TryFindValue(SqlSelect, out _Value, Parameters) ?
                   _Value : DefaultValue);
        }
Exemplo n.º 2
0
        public bool TryFindSumValue <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.GetSqlSum(),
                                             "(", 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));
        }