Пример #1
0
        /// <summary>
        /// Delete using the expression.
        /// e.g. entity.LogLevel == 1
        /// </summary>
        /// <param name="expression">Expression to use for deletion.</param>
        public virtual void Delete(Expression <Func <T, bool> > expression)
        {
            string filter = RepositoryExpressionHelper.BuildSinglePropertyCondition <T>(expression);
            string sql    = string.Format("delete from {0} where {1}", TableName, filter);

            _db.ExecuteNonQueryText(sql, null);
        }
Пример #2
0
        /// <summary>
        /// Delete using the expression.
        /// e.g. entity.LogLevel == 1
        /// </summary>
        /// <param name="expression">Expression to use for deletion.</param>
        public override void Delete(Expression <Func <T, bool> > expression)
        {
            string filter = RepositoryExpressionHelper.BuildSinglePropertyCondition <T>(expression);

            DataRow[] rows = _table.Select(filter);
            foreach (var row in rows)
            {
                _table.Rows.Remove(row);
            }
        }
Пример #3
0
        /// <summary>
        /// Group(date)(CreateDate)
        /// </summary>
        /// <typeparam name="TGroup">Type of group to use.</typeparam>
        /// <param name="exp">Matching expression.</param>
        /// <returns>List of key/value pairs.</returns>
        public virtual List <KeyValuePair <TGroup, int> > Group <TGroup>(Expression <Func <T, object> > exp)
        {
            string propName = RepositoryExpressionHelper.GetPropertyName <T>(exp);

            return(InternalGroup <TGroup>(propName, null));
        }
Пример #4
0
        /// <summary>
        /// Sum using expression. e.g. p => p.FirstName;
        /// </summary>
        /// <typeparam name="TVal">Type of values to return.</typeparam>
        /// <param name="exp">Matching expression.</param>
        /// <returns>List of distinct values.</returns>
        public virtual List <TVal> Distinct <TVal>(Expression <Func <T, object> > exp)
        {
            string propName = RepositoryExpressionHelper.GetPropertyName <T>(exp);

            return(InternalDistinct <TVal>(propName, null));
        }
Пример #5
0
 /// <summary>
 /// Sum using expression. e.g. p => p.FirstName;
 /// </summary>
 /// <param name="exp">Expression representing the column name via property name</param>
 /// <returns>Average of entities.</returns>
 public virtual double Avg(Expression <Func <T, object> > exp)
 {
     return(Avg(RepositoryExpressionHelper.GetPropertyName <T>(exp)));
 }