public static ASimpleRelation getSimpleRelation(Relator.Unary unaryProperty, string searchPhrase, Track.Property trackProperty )
        {
            string mappedTrackPropertyPropertyAsString = Track.getChildPropertyAsString(trackProperty);

            if( trackProperty == Track.Property.Bpm || trackProperty == Track.Property.Year)
                return new IntSearch(
                    unaryProperty,
                    int.Parse(searchPhrase),
                    trackProperty.ToString(),
                    mappedTrackPropertyPropertyAsString );
            else
                return new StringSearch(
                    unaryProperty,
                    searchPhrase,
                    trackProperty.ToString(),
                    mappedTrackPropertyPropertyAsString );
        }
        /// <summary>
        /// With explicit sorting.
        /// </summary>
        public static IList<Track> getTrackListing(ARelation relation, Track.Property sortExpression, SortDirection sortDirection)
        {
            ICriteria criteria = NHibernateSessionManager.Instance.GetSession().CreateCriteria(typeof(Track));
            ISet<string> aliases = new HashedSet<string>();
            Junction junction = relation.BinaryRelator == Relator.Binary.AND ? new Conjunction() : new Disjunction() as Junction;

            foreach(ARelation relatum in relation.Relata)
                TrackSearch_Service.loadJunctions(junction, relatum, aliases, criteria);
            criteria.Add(junction);
            if(!aliases.Contains(sortExpression.ToString().ToLower()))
                criteria.CreateAlias(sortExpression.ToString(), sortExpression.ToString().ToLower());

            Order order;
            if(sortDirection == SortDirection.Ascending)
                order = Order.Asc(String.Format("{0}.{1}", sortExpression.ToString().ToLower(), Track.getChildPropertyAsString(sortExpression)));
            else
                order = Order.Desc(String.Format("{0}.{1}", sortExpression.ToString().ToLower(), Track.getChildPropertyAsString(sortExpression)));
            criteria.AddOrder(order);
            return criteria.List<Track>();
        }
 public SearchItem_Between_Dto(Relator.Unary unary, Track.Property property, string phrase1, string phrase2)
     : base(unary, property, phrase1, phrase2)
 {
     Check.Require(
         property == Track.Property.Bpm || property == Track.Property.Year || property == Track.Property.Laenge, String.Format(
         "Argument must be of type {0}, {1}, {2}. It's of type {3}",
         Track.Property.Bpm.ToString(),
         Track.Property.Laenge.ToString(),
         Track.Property.Year.ToString(),
         property.ToString()));
 }