@@ -45,7 +45,7 @@ public Expression BuildSelect(Expression select, Expression where)
4545 {
4646 if ( select is DbSelectExpression _select )
4747 {
48- return new DbSelectExpression ( _select . QueryObject , _select . Type , _select . From , _select . Columns , where , _select . OrderBy , _select . GroupBy , _select . IsDistinct , _select . Take ) ;
48+ return new DbSelectExpression ( _select . QueryObject , _select . Type , _select . From , _select . Columns , where , _select . OrderBy , _select . GroupBy , _select . IsDistinct , _select . Take , _select . Skip ) ;
4949 }
5050
5151 throw new NotSupportedException ( ) ;
@@ -55,7 +55,7 @@ public Expression BuildSelect(Expression expression, bool isDistinct)
5555 {
5656 if ( expression is DbSelectExpression select )
5757 {
58- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , select . GroupBy , isDistinct , select . Take ) ;
58+ return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , select . GroupBy , isDistinct , select . Take , select . Skip ) ;
5959 }
6060
6161 throw new NotSupportedException ( ) ;
@@ -65,7 +65,7 @@ public Expression BuildSelect(Expression expression, int count)
6565 {
6666 if ( expression is DbSelectExpression select )
6767 {
68- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , Expression . Constant ( count ) ) ;
68+ return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , Expression . Constant ( count ) , select . Skip ) ;
6969 }
7070
7171 throw new NotSupportedException ( ) ;
@@ -98,7 +98,7 @@ public Expression BuildSelect(Expression expression, IDbEntityProperty property)
9898 typeof ( SysLinq . IQueryable < > ) . MakeGenericType ( property . PropertyType ) ,
9999 select . From ,
100100 select . Columns . Where ( x => x . PropertyName . Equals ( property . PropertyName , StringComparison . CurrentCulture ) ) ,
101- select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , select . Take ) ;
101+ select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , select . Take , select . Skip ) ;
102102 }
103103
104104 throw new NotSupportedException ( ) ;
@@ -108,7 +108,7 @@ public Expression BuildSelect(Expression expression, IEnumerable<DbOrderByDeclar
108108 {
109109 if ( expression is DbSelectExpression select )
110110 {
111- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , orderBy , select . GroupBy , select . IsDistinct , select . Take ) ;
111+ return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , orderBy , select . GroupBy , select . IsDistinct , select . Take , select . Skip ) ;
112112 }
113113
114114 throw new NotSupportedException ( ) ;
@@ -117,7 +117,7 @@ public Expression BuildSelect(Expression expression, IEnumerable<Expression> gro
117117 {
118118 if ( expression is DbSelectExpression select )
119119 {
120- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , groupBy , select . IsDistinct , select . Take ) ;
120+ return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , groupBy , select . IsDistinct , select . Take , select . Skip ) ;
121121 }
122122
123123 throw new NotSupportedException ( ) ;
@@ -136,7 +136,7 @@ public Expression BuildSelect<TEntity, TColumn>(Expression expression, Expressio
136136 {
137137 if ( expression is DbSelectExpression select )
138138 {
139- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns . Where ( col => col . PropertyName == selector . GetPropertyName ( ) ) , select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , select . Take ) ;
139+ return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns . Where ( col => col . PropertyName == selector . GetPropertyName ( ) ) , select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , select . Take , select . Skip ) ;
140140 }
141141 return expression ;
142142 }
@@ -501,7 +501,7 @@ protected virtual Expression BuildQuery(Expression expression)
501501 }
502502 else if ( call . Method . IsSkip ( ) )
503503 {
504- throw Error . NotImplemented ( ) ;
504+ return BuildSelectWithSkip ( call ) ;
505505 }
506506 else
507507 {
@@ -534,6 +534,35 @@ private static Type[] GetTypeArguments(LambdaExpression expression)
534534 return Array . Empty < Type > ( ) ;
535535 }
536536
537+ private Expression BuildSelectWithSkip ( MethodCallExpression expression )
538+ {
539+ if ( ! ( expression is null ) )
540+ {
541+ DbSelectExpression select = null ;
542+ Expression skip = null ;
543+
544+ foreach ( var argument in expression . Arguments )
545+ {
546+ if ( argument is DbSelectExpression _select )
547+ {
548+ select = _select ;
549+ }
550+ else if ( argument is ConstantExpression constant )
551+ {
552+ skip = constant ;
553+ }
554+ }
555+
556+ return DbExpression . DbSelect (
557+ select ,
558+ select . Take ,
559+ skip
560+ ) ;
561+ }
562+
563+ return expression ;
564+ }
565+
537566 private Expression BuildSelectWithTake ( MethodCallExpression expression )
538567 {
539568 if ( ! ( expression is null ) )
@@ -555,7 +584,8 @@ private Expression BuildSelectWithTake(MethodCallExpression expression)
555584
556585 return DbExpression . DbSelect (
557586 select ,
558- take
587+ take ,
588+ select . Skip
559589 ) ;
560590 }
561591
0 commit comments