Example #1
0
        public ITable Clone()
        {
            PassThroughTable result = new PassThroughTable(baseTable);

            result.advanceTable = advanceTable.Clone();
            result.populated    = populated;
            return(result);
        }
        public static ITable <T> OrderByDescending <T, K>(this ITable <T> source, Expression <Func <T, K> > keySelector)
        {
            source = source.Clone();

            source.IsDirty = true;

            source.Query.OrderByClause = "order by " + source.Converter.ConvertToString(keySelector) + " desc";
            return(source);
        }
        public static ITable <T> ThenBy <T, K>(this ITable <T> source, Expression <Func <T, K> > keySelector)
        {
            source = source.Clone();

            source.IsDirty = true;

            source.Query.OrderByClause += ", " + source.Converter.ConvertToString(keySelector);
            return(source);
        }
        public static ITable <T> Select <T, S>(this ITable <T> source, Expression <Func <T, S> > selector)
        {
            source = source.Clone();

            source.IsDirty = true;

            //if (selector.Body is NewExpression)
            //{
            //    LinqToNPathConverter.CreateLoadspan((NewExpression)selector.Body, source.Query);
            //    //throw new NotSupportedException("Not supported yet");
            //}

            //if (selector.Body is MemberInitExpression)
            //{
            //    LinqToNPathConverter.CreateLoadspan((MemberInitExpression)selector.Body, source.Query);
            //}

            return(source);
        }
        public static ITable <T> Where <T>(this ITable <T> source, Expression <Func <T, bool> > predicate)
        {
            source = source.Clone();

            source.IsDirty = true;

            string whereClause = source.Converter.ConvertToString(predicate);

            if (source.Query.WhereClause != "")
            {
                source.Query.WhereClause += string.Format(" and ({0})", whereClause);
            }
            else
            {
                source.Query.WhereClause = string.Format("where ({0})", whereClause);
            }

            return(source);
        }