Пример #1
0
        public IFilteredQueryOver <TEntity> FilterBy(PropertyProjection propertyProjection)
        {
            propertyProjection.ThrowIfNull("propertyProjection");

            AddFilter(propertyProjection.PropertyName, propertyProjection);
            return(this);
        }
Пример #2
0
        public void SelectDistinctUsingPropertyProjectionThrowsWhenProjectionIsNull()
        {
            PropertyProjection p = null;

            Assert
            .That
            (
                () =>
            {
                DummyQuery <UserEntity>()
                .Distinct().Select(p);
            },
                Throws.InstanceOf <ArgumentNullException>()
            );

            Assert
            .That
            (
                () =>
            {
                DummyQuery <UserEntity>()
                .Distinct()
                .Select <UserDto>(p);
            },
                Throws.InstanceOf <ArgumentNullException>()
            );
        }
Пример #3
0
        public UserGroup GetByName(string groupName)
        {
            PropertyProjection name = Projections.Property <UserGroup>(s => s.Name);

            return(CreateDetachedCriteria().Add(Restrictions.Eq(name, groupName)).GetExecutableCriteria(
                       CurrentSession).UniqueResult <UserGroup>());
        }
Пример #4
0
        public IList <string> GetOnlineUsers(DateTime time)
        {
            PropertyProjection projections = Projections.Property <User.OtherUserInfo>(s => s.LastActivityDate);
            SimpleExpression   re          = Restrictions.Ge(projections, time);

            return
                (CreateDetachedCriteria()
                 .CreateCriteria("Other")
                 .Add(re)
                 .SetProjection(Projections.Property <User>(s => s.LoginId))
                 .GetExecutableCriteria(CurrentSession)
                 .List <string>());
        }
Пример #5
0
        /// <summary>
        ///     获取在某日期之后处于活动状态的用户
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public int GetActivityDateNumber(DateTime time)
        {
            PropertyProjection projections = Projections.Property <User.OtherUserInfo>(s => s.LastActivityDate);
            SimpleExpression   re          = Restrictions.Ge(projections, time);

            return
                (CreateCriteria()
                 .CreateCriteria("Other")
                 .Add(re)
                 .SetProjection(Projections.RowCount())
                 .UniqueResult <Int32>());
            //return Count(Restrictions.Le(projections, time));
        }
    public override SqlString ToGroupSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery,
                                               IDictionary <string, IFilter> enabledFilters)
    {
        SqlStringBuilder result = new SqlStringBuilder();

        for (int index = 0; index < _projections.Length; index++)
        {
            PropertyProjection projection = _projections[index];
            if (index > 0)
            {
                result.Add(",");
            }
            result.Add(StringHelper.RemoveAsAliasesFromSql(projection.ToSqlString(criteria, 0, criteriaQuery, enabledFilters)));
        }
        result.Add(") as tbly");
        return(result.ToSqlString());
    }
    public override SqlString ToSqlString(ICriteria criteria, int position, ICriteriaQuery criteriaQuery, IDictionary <string, IFilter> enabledFilters)
    {
        SqlStringBuilder result = new SqlStringBuilder()
                                  .Add(" count(*) as y")
                                  .Add(position.ToString())
                                  .Add("_ from ( select ");

        for (int index = 0; index < _projections.Length; index++)
        {
            PropertyProjection projection = _projections[index];
            if (index > 0)
            {
                result.Add(",");
            }
            result.Add(projection.ToSqlString(criteria, ++position, criteriaQuery, enabledFilters));
        }
        result.Add(" ");
        return(result.ToSqlString());
    }
 public IProjection GetDistinctProperty(PropertyProjection projection)
 {
     return(Projections.Distinct(projection));
 }