Exemplo n.º 1
0
        public double SumAsDouble(string attrDefName)
        {
            double count = 0;
            var    sql   = SqlQueryBuilder.Build(DataContext, Def);

            sql.AddAttribute(attrDefName, SqlQuerySummaryFunction.Sum);

            using (var reader = new SqlQueryReader(DataContext, sql))
            {
                reader.Open();
                if (reader.Read())
                {
                    if (!reader.IsDbNull(0))
                    {
                        if (reader.Reader.GetFieldType(0) == typeof(double))
                        {
                            count = reader.GetDouble(0);
                        }
                        else if (reader.Reader.GetFieldType(0) == typeof(decimal))
                        {
                            count = (double)reader.GetDecimal(0);
                        }
                    }
                }
                reader.Close();
            }
            return(count);
        }