コード例 #1
0
        public static LinqToSolrSort Create(Expression fieldExp, SolrSortTypes order)
        {
            var o = new LinqToSolrSort();

            var fb = fieldExp as MemberExpression;

            if (fb != null)
            {
#if NET40 || NET35 || PORTABLE40
                var dataMemberAttribute =
                    Attribute.GetCustomAttribute(fb.Member, typeof(JsonPropertyAttribute), true) as
                    JsonPropertyAttribute;
#else
                var dataMemberAttribute = fb.Member.GetCustomAttribute <JsonPropertyAttribute>();
#endif
                o.Name = !string.IsNullOrEmpty(dataMemberAttribute?.PropertyName)
                    ? dataMemberAttribute.PropertyName
                    : fb.Member.Name;


                o.Order = order;


                return(o);
            }

            return(null);
        }
コード例 #2
0
        public LinqToSolrQuery AddSorting(Expression field, SolrSortTypes order)
        {
            Sortings.Add(LinqToSolrSort.Create(field, order));

            return(this);
        }