@@ -23,26 +23,6 @@ public partial class DbSqlQueryBuilder
2323 #endregion
2424
2525 #region Build Select
26- public Expression BuildSelect ( System . Linq . IQueryable queryable )
27- {
28- if ( queryable . IsNull ( ) )
29- {
30- throw new ArgumentNullException ( nameof ( queryable ) ) ;
31- }
32-
33- return DbExpression . DbSelect ( queryable , queryable . Expression . Type , DbTable ) ;
34- }
35-
36- public Expression BuildSelect ( System . Linq . IQueryable queryable , Expression where )
37- {
38- if ( queryable . IsNull ( ) )
39- {
40- throw new ArgumentNullException ( nameof ( queryable ) ) ;
41- }
42-
43- return new DbSelectExpression ( queryable , queryable . Expression . Type , DbTable , DbTable . Columns , where ) ;
44- }
45-
4626 public Expression BuildSelect ( Expression select , Expression where )
4727 {
4828 if ( select is DbSelectExpression _select )
@@ -63,15 +43,6 @@ public Expression BuildSelect(Expression expression, bool isDistinct)
6343 throw new NotSupportedException ( ) ;
6444 }
6545
66- public Expression BuildSelect ( Expression expression , int count )
67- {
68- if ( expression is DbSelectExpression select )
69- {
70- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , select . GroupBy , select . IsDistinct , Expression . Constant ( count ) , select . Skip ) ;
71- }
72-
73- throw new NotSupportedException ( ) ;
74- }
7546 public Expression BuildSelect ( Expression expression , int pageNumber , int pageSize )
7647 {
7748 if ( expression is DbSelectExpression select )
@@ -106,34 +77,6 @@ public Expression BuildSelect(Expression expression, IDbEntityProperty property)
10677 throw new NotSupportedException ( ) ;
10778 }
10879
109- public Expression BuildSelect ( Expression expression , IEnumerable < DbOrderByDeclaration > orderBy )
110- {
111- if ( expression is DbSelectExpression select )
112- {
113- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , orderBy , select . GroupBy , select . IsDistinct , select . Take , select . Skip ) ;
114- }
115-
116- throw new NotSupportedException ( ) ;
117- }
118- public Expression BuildSelect ( Expression expression , IEnumerable < Expression > groupBy )
119- {
120- if ( expression is DbSelectExpression select )
121- {
122- return new DbSelectExpression ( select . QueryObject , select . Type , select . From , select . Columns , select . Where , select . OrderBy , groupBy , select . IsDistinct , select . Take , select . Skip ) ;
123- }
124-
125- throw new NotSupportedException ( ) ;
126- }
127-
128- public Expression BuildSelect ( Expression select , DbExpressionType eType , IEnumerable < Expression > expressions )
129- {
130- if ( select is DbSelectExpression )
131- {
132- throw new NotImplementedException ( ) ;
133- }
134- return select ;
135- }
136-
13780 private Expression BuildSelect ( Expression expression , IEnumerable < DbColumnDeclaration > columns )
13881 {
13982 if ( expression is DbSelectExpression select )
@@ -164,51 +107,6 @@ public Expression BuildWhere(DbExpression expression, LambdaExpression predicate
164107 DbExpression . DbWhere ( method , new Expression [ ] { expression , predicate } ) ) ;
165108 }
166109
167- public Expression BuildWhere ( DbTableExpression table , Expression where , Type type , LambdaExpression predicate )
168- {
169- if ( where . IsNotNull ( ) )
170- {
171- if ( predicate is null )
172- {
173- throw new ArgumentNullException ( nameof ( predicate ) ) ;
174- }
175-
176- if ( ( ( DbExpressionType ) where . NodeType ) == DbExpressionType . Where &&
177- where is DbWhereExpression _where )
178- {
179- Expression
180- logical = DbWherePredicateBuilder . GetBodyExpression ( _where . GetArgument ( 1 ) , predicate . Body , DbGroupOperator . AndAlso ) ;
181- predicate = BuildLambda ( logical , LambdaType . Predicate ) as LambdaExpression ;
182- }
183- else
184- {
185- throw new NotSupportedException ( ) ;
186- }
187- }
188-
189- throw Error . NotImplemented ( ) ;
190- }
191-
192- //public Expression BuildWhere(DbTableExpression table, Expression where, Type type, Expression predicate)
193- //{
194- // LambdaExpression lambda = null;
195-
196- // if (predicate is UnaryExpression unary)
197- // {
198- // if (unary.Operand is LambdaExpression _unary)
199- // {
200- // lambda = _unary;
201- // }
202- // }
203-
204- // return BuildWhere(table, where, type, lambda);
205- //}
206-
207- public Expression BuildWherePredicate ( Expression collection , Expression lambda )
208- {
209- return BuildCall ( "Where" , collection , lambda ) ;
210- }
211-
212110 public Expression BuildWhereFindByIDPredicate ( DbExpression expression , object [ ] keyData , params string [ ] keyNames )
213111 {
214112 if ( keyData . IsNull ( ) )
@@ -246,24 +144,8 @@ public Expression BuildJoin(JoinType type, Expression left, Expression right)
246144 #endregion
247145
248146 #region Lambda
249- public Expression BuildCall ( string nameofCallee , Expression collection , Expression lambda )
250- {
251- if ( lambda . IsNotNull ( ) )
252- {
253- return Expression . Call (
254- typeof ( System . Linq . Queryable ) ,
255- nameofCallee ,
256- GetTypeArguments ( ( LambdaExpression ) lambda ) ,
257- GetMethodCall ( collection ) ?? Expression . Parameter ( GetTypeOf ( typeof ( ISubSonicCollection < > ) , DbEntity . EntityModelType ) ) ,
258- lambda ) ;
259- }
260- return lambda ;
261- }
262-
263147 public Expression BuildLambda ( Expression body , LambdaType @call , params string [ ] properties )
264148 {
265- Expression result ;
266-
267149 switch ( call )
268150 {
269151 case Infrastructure . LambdaType . Predicate :
@@ -538,27 +420,6 @@ protected virtual Expression BuildQuery(Expression expression)
538420 return expression ?? DbEntity . Table ;
539421 }
540422
541- private Type GetTypeOf ( Type type , params Type [ ] types )
542- {
543- return type . IsGenericType ? type . MakeGenericType ( types ) : type ;
544- }
545-
546- private static Type [ ] GetTypeArguments ( LambdaExpression expression )
547- {
548- if ( expression . IsNotNull ( ) )
549- {
550- IEnumerable < Type > types = expression . Parameters . Select ( Param => Param . Type ) ;
551-
552- if ( ! expression . Body . Type . IsBoolean ( ) )
553- { // not a predicate
554- types = types . Union ( new [ ] { expression . Body . Type } ) ;
555- }
556-
557- return types . ToArray ( ) ;
558- }
559- return Array . Empty < Type > ( ) ;
560- }
561-
562423 private Expression BuildSelectWithExpression ( MethodCallExpression expression )
563424 {
564425 if ( ! ( expression is null ) )
0 commit comments