public static FilterQuery <Person.Model.Entity.Person> GetQuery(this SearchPersonFilter filter, IQueryRepositoryFactory factory)
        {
            var personQuery = factory.GetRepository <Person.Model.Entity.Person>().Query();
            var criteria    = GetCriterias(filter).Where(x => x != null);

            foreach (var c in criteria)
            {
                personQuery = from query in personQuery
                              join criteriaQuery in c.GetQuery(factory)
                              on query.Id equals criteriaQuery
                              select query;
            }

            //это не очень хорошо
            personQuery = personQuery.Distinct();

            return(new FilterQuery <Person.Model.Entity.Person>
            {
                Query = personQuery
                        .GenericSort(filter.SortBy, persons => persons.OrderBy(x => x.Id))
                        .Skip(filter.PageSize * (filter.PageNumber - 1))
                        .Take(filter.PageSize),

                PageNumber = filter.PageNumber,
                PageSize = filter.PageSize,
                TotalCount = personQuery.Count()
            });
        }
 public IQueryable <int> GetQuery(IQueryRepositoryFactory f)
 {
     return(f.GetRepository <Person.Model.Entity.Person>().Query().Where(_exp).Select(x => x.Id));
 }