11using System ;
2+ using System . Diagnostics . Contracts ;
23using System . Linq . Expressions ;
34using System . Linq ;
45using System . Collections . Generic ;
@@ -22,53 +23,64 @@ internal WhereClause(string table, string selection, Expression where)
2223
2324 public OrderByClause < T > OrderBy < TValue > ( Expression < Func < T , TValue > > orderExpr )
2425 {
26+ Contract . Requires ( orderExpr != null ) ;
2527 return CreateOrderBy ( orderExpr , true ) ;
2628 }
2729
2830 public OrderByClause < T > OrderByDescending < TValue > ( Expression < Func < T , TValue > > orderExpr )
2931 {
32+ Contract . Requires ( orderExpr != null ) ;
3033 return CreateOrderBy ( orderExpr , false ) ;
3134 }
3235
3336 private OrderByClause < T > CreateOrderBy < TValue > ( Expression < Func < T , TValue > > orderExpr , bool asc )
3437 {
38+ Contract . Requires ( orderExpr != null ) ;
39+
3540 var orderBy = new List < Tuple < string , bool > > ( ) ;
3641 orderBy . Add ( orderExpr . CompileOrderByExpression ( asc ) ) ;
3742 return new OrderByClause < T > ( table , selection , where , orderBy ) ;
3843 }
3944
4045 public WhereClause < T > Where < U , V , W , X , Y , Z > ( Expression < Func < T , U , V , W , X , Y , Z , bool > > predExpr )
4146 {
47+ Contract . Requires ( predExpr != null ) ;
4248 return this . Where ( ( LambdaExpression ) predExpr ) ;
4349 }
4450
4551 public WhereClause < T > Where < U , V , W , X , Y > ( Expression < Func < T , U , V , W , X , Y , bool > > predExpr )
4652 {
53+ Contract . Requires ( predExpr != null ) ;
4754 return this . Where ( ( LambdaExpression ) predExpr ) ;
4855 }
4956
5057 public WhereClause < T > Where < U , V , W , X > ( Expression < Func < T , U , V , W , X , bool > > predExpr )
5158 {
59+ Contract . Requires ( predExpr != null ) ;
5260 return this . Where ( ( LambdaExpression ) predExpr ) ;
5361 }
5462
5563 public WhereClause < T > Where < U , V , W > ( Expression < Func < T , U , V , W , bool > > predExpr )
5664 {
65+ Contract . Requires ( predExpr != null ) ;
5766 return this . Where ( ( LambdaExpression ) predExpr ) ;
5867 }
5968
6069 public WhereClause < T > Where < U , V > ( Expression < Func < T , U , V , bool > > predExpr )
6170 {
71+ Contract . Requires ( predExpr != null ) ;
6272 return this . Where ( ( LambdaExpression ) predExpr ) ;
6373 }
6474
6575 public WhereClause < T > Where < U > ( Expression < Func < T , U , bool > > predExpr )
6676 {
77+ Contract . Requires ( predExpr != null ) ;
6778 return this . Where ( ( LambdaExpression ) predExpr ) ;
6879 }
6980
7081 public WhereClause < T > Where ( Expression < Func < T , bool > > predExpr )
7182 {
83+ Contract . Requires ( predExpr != null ) ;
7284 return this . Where ( ( LambdaExpression ) predExpr ) ;
7385 }
7486
@@ -86,6 +98,7 @@ private WhereClause<T> Where(LambdaExpression lambda)
8698 /// <returns>A new <see cref="SQLitePCL.pretty.Orm.TableQuery<T>"/>.</returns>
8799 public LimitClause Take ( int n )
88100 {
101+ Contract . Requires ( n >= 0 ) ;
89102 return new LimitClause ( table , selection , where , new List < Tuple < string , bool > > ( ) , n , null ) ;
90103 }
91104
@@ -96,6 +109,7 @@ public LimitClause Take(int n)
96109 /// <returns>A new <see cref="SQLitePCL.pretty.Orm.TableQuery<T>"/>.</returns>
97110 public LimitClause Skip ( int n )
98111 {
112+ Contract . Requires ( n >= 0 ) ;
99113 return new LimitClause ( table , selection , where , new List < Tuple < string , bool > > ( ) , null , n ) ;
100114 }
101115
@@ -107,6 +121,7 @@ public LimitClause Skip(int n)
107121 /// <returns>A new <see cref="SQLitePCL.pretty.Orm.TableQuery<T>"/>.</returns>
108122 public LimitClause ElementAt ( int index )
109123 {
124+ Contract . Requires ( index >= 0 ) ;
110125 return Skip ( index ) . Take ( 1 ) ;
111126 }
112127
0 commit comments