Beispiel #1
0
        static string sortIndex(this iTypeSerializer ser, MemberInfo mi, out bool indexDirectionPositive, out bool multi)
        {
            IndexForColumn[] indices = ser.indicesFromColumn(mi);

            IndexForColumn found = null;

            foreach (var i in indices)
            {
                if (0 != i.columnIndex)
                {
                    continue;                           // For sorting, the column have to be the first on the index
                }
                if (i.primary)
                {
                    // Primary indices should be the best for performance
                    found = i;
                    break;
                }
                if (null == found)
                {
                    found = i;
                }
            }
            if (null == found)
            {
                throw new ArgumentException("No sort index found for the column {0}".formatWith(mi.Name));
            }

            indexDirectionPositive = found.indexDirectionPositive;
            multi = mi.getColumnAttribute().isMultiValued;
            return(found.indexName);
        }
Beispiel #2
0
        static SearchQuery <tRow> fullTextQuery <tRow>(iTypeSerializer ser, ParameterExpression eRecord, ParameterExpression eArgument, Expression eLeft, Expression eRight, int argsCount) where tRow : new()
        {
            HasParam hp = new HasParam(eRecord);

            bool leftParam = hp.hasParameter(eLeft);

            if (!leftParam)
            {
                throw new NotSupportedException("Full-text queries must have column as the first argument");
            }
            MemberInfo column = parseColumn(eRecord, eLeft);

            bool rightParam = hp.hasParameter(eRight);

            if (rightParam)
            {
                throw new NotSupportedException("Full-text queries can't include column in the second argument");
            }
            Func <object, object> arg = parseConstant(eArgument, eRight);

            IndexForColumn[] inds = ser.indicesFromColumn(column);
            IndexForColumn   ind  = inds.FirstOrDefault(i => i.columnIndex == 0 && i.attrib is Attributes.EseTupleIndexAttribute);

            if (null == ind)
            {
                throw new NotSupportedException("Failed to parse full-text search query: no suitable index found");
            }

            string indName = ind.indexName;
            Action <Recordset <tRow>, object> act = (rs, a) => rs.filterFindSubstring(indName, arg(a));

            return(new SearchQuery <tRow>(act, argsCount, true));
        }
Beispiel #3
0
        /// <summary>Compile query to sort the table by the index.</summary>
        public static SortQuery <tRow> sort <tRow, tKey>(iTypeSerializer ser, Expression <Func <tRow, tKey> > exp, bool descending) where tRow : new()
        {
            var me = exp.Body as MemberExpression;

            if (null == me)
            {
                throw new NotSupportedException("Currently, orderBy[Descending] only supports ordering by a single column.");
            }

            IndexForColumn[] indices = ser.indicesFromColumn(me.Member);

            bool indexDirectionPositive, multi;

            string ind = ser.sortIndex(me.Member, out indexDirectionPositive, out multi);

            bool shouldInvert = descending ^ (!indexDirectionPositive);

            return(new SortQuery <tRow>(r => r.filterSort(ind, shouldInvert), multi));
        }
Beispiel #4
0
 /// <summary>Look up the ESENT indices</summary>
 public void lookupIndices(iTypeSerializer ser)
 {
     indices = ser.indicesFromColumn(column);
 }