@@ -389,7 +389,7 @@ public int Execute<T>(IQueryable<T> query, Expression<Func<T, T>> updateFactory)
389389 }
390390 }
391391#endif
392- }
392+ }
393393
394394#if EF5 || EF6
395395 /// <summary>Creates a command to execute the batch operation.</summary>
@@ -488,9 +488,9 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
488488 CommandTextWhileDelayTemplate :
489489 CommandTextWhileTemplate :
490490#endif
491- isPostgreSQL ? CommandTextTemplate_PostgreSQL :
491+ isPostgreSQL ? CommandTextTemplate_PostgreSQL :
492492 isOracle ? CommandTextOracleTemplate :
493- isMySql ? CommandTextTemplate_MySQL :
493+ isMySql ? CommandTextTemplate_MySQL :
494494 isSqlCe ? CommandTextTemplateSqlCe :
495495 isSQLite ? CommandTextTemplate_SQLite :
496496 isHana ? CommandTextTemplate_Hana :
@@ -515,7 +515,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
515515 primaryKeys = string . Join ( Environment . NewLine + "AND " , columnKeys . Select ( x => string . Concat ( tableName + "." , EscapeName ( x , isMySql , isOracle , isPostgreSQL , isHana ) , " = B." , EscapeName ( x , isMySql , isOracle , isPostgreSQL , isHana ) , "" ) ) ) ;
516516
517517 setValues = string . Join ( "," + Environment . NewLine , values . Select ( ( x , i ) => x . Item2 is ConstantExpression ?
518- string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL , isHana ) , " = " , ( ( ConstantExpression ) x . Item2 ) . Value . ToString ( ) . Replace ( "B.[" , "[" ) ) :
518+ string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL , isHana ) , " = " , ( ( ConstantExpression ) x . Item2 ) . Value . ToString ( ) . Replace ( "B.[" , "[" ) ) :
519519 string . Concat ( EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL , isHana ) , " = @zzz_BatchUpdate_" , i ) ) ) ;
520520 }
521521 else if ( isOracle || isPostgreSQL || isHana )
@@ -542,7 +542,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
542542
543543 // GET updateSetValues
544544 setValues = string . Join ( "," + Environment . NewLine , values . Select ( ( x , i ) => x . Item2 is ConstantExpression ?
545- string . Concat ( "A." , EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL , isHana ) , " = " , ( ( ConstantExpression ) x . Item2 ) . Value ) :
545+ string . Concat ( "A." , EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL , isHana ) , " = " , ( ( ConstantExpression ) x . Item2 ) . Value ) :
546546 string . Concat ( "A." , EscapeName ( x . Item1 , isMySql , isOracle , isPostgreSQL , isHana ) , " = @zzz_BatchUpdate_" , i ) ) ) ;
547547 }
548548
@@ -608,7 +608,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
608608 {
609609 if ( isOracle && paramValue is bool )
610610 {
611- parameter . Value = ( Boolean ) paramValue ? 1 : 0 ;
611+ parameter . Value = ( Boolean ) paramValue ? 1 : 0 ;
612612 }
613613 else
614614 {
@@ -620,7 +620,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
620620 if ( parameter is SqlParameter )
621621 {
622622 var sqlParameter = ( SqlParameter ) parameter;
623-
623+
624624 if ( paramNullValue != null && paramNullValue . Type == typeof ( byte [ ] ) )
625625 {
626626 sqlParameter. SqlDbType = SqlDbType . VarBinary ;
@@ -891,7 +891,18 @@ public DbCommand CreateCommand(IQueryable query, IEntityType entity, List<Tuple<
891891 // ADD Parameter
892892 foreach ( var relationalParameter in relationalCommand . Parameters )
893893 {
894- var parameter = queryContext. ParameterValues[ relationalParameter . InvariantName ] ;
894+ object parameter;
895+ if ( ! queryContext . ParameterValues . TryGetValue ( relationalParameter . InvariantName , out parameter ) )
896+ {
897+ if ( relationalParameter . InvariantName . StartsWith ( "__ef_filter" ) )
898+ {
899+ throw new Exception ( "Please use 'IgnoreQueryFilters()'. The HasQueryFilter is not yet supported." ) ;
900+ }
901+ else
902+ {
903+ throw new Exception ( "The following parameter could not be found: " + relationalParameter ) ;
904+ }
905+ }
895906
896907 var param = command. CreateParameter ( ) ;
897908 param. CopyFrom ( relationalParameter , parameter ) ;
@@ -1013,36 +1024,36 @@ public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expres
10131024
10141025#endif
10151026 // GET updateFactory command
1016- var values = ResolveUpdateFromQueryDictValues( updateFactory ) ;
1027+ var values = ResolveUpdateFromQueryDictValues( updateFactory ) ;
10171028 var destinationValues = new List < Tuple < string , object >> ( ) ;
10181029
10191030 int valueI = - 1 ;
10201031 foreach ( var value in values)
1021- {
1032+ {
10221033 valueI ++ ;
1023-
1034+
10241035#if EF5 || EF6
10251036 // FIND the mapped column
10261037 var column = mapping . ScalarProperties . Find ( x => x . Name == value . Key ) ;
1027- string columnName;
1028-
1029- if ( column != null )
1030- {
1031- columnName = column. ColumnName;
1032- }
1033- else
1034- {
1035- var accessor = mapping. ScalarAccessors. Find( x => x . AccessorPath == value . Key ) ;
1036- if ( accessor == null )
1037- {
1038- throw new Exception ( "The destination column could not be found:" + value . Key ) ;
1039- }
1040-
1041- columnName = accessor . ColumnName ;
1042- }
1043-
1044-
1045-
1038+ string columnName;
1039+
1040+ if ( column != null )
1041+ {
1042+ columnName = column. ColumnName;
1043+ }
1044+ else
1045+ {
1046+ var accessor = mapping. ScalarAccessors. Find( x => x . AccessorPath == value . Key ) ;
1047+ if ( accessor == null )
1048+ {
1049+ throw new Exception ( "The destination column could not be found:" + value . Key ) ;
1050+ }
1051+
1052+ columnName = accessor . ColumnName ;
1053+ }
1054+
1055+
1056+
10461057#elif EFCORE
10471058
10481059 var property = entity. FindProperty( value . Key ) ;
@@ -1077,7 +1088,7 @@ public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expres
10771088#if EF5 || EF6
10781089 // GET the select command text
10791090 var commandText = ( ( IQueryable ) result ) . ToString ( ) ;
1080- var parameters = ( ( IQueryable ) result ) . GetObjectQuery ( ) . Parameters ;
1091+ var parameters = ( ( IQueryable ) result ) . GetObjectQuery ( ) . Parameters ;
10811092
10821093 // GET the 'value' part
10831094 var pos = commandText . IndexOf ( "AS [value]" + Environment . NewLine + "FROM" , StringComparison . InvariantCultureIgnoreCase ) != - 1 ?
@@ -1149,7 +1160,7 @@ public List<Tuple<string, object>> GetInnerValues<T>(IQueryable<T> query, Expres
11491160 valueSql = valueSql. Substring ( 0 , valueSql . LastIndexOf ( '[' ) - 4 ) ;
11501161 }
11511162
1152- if ( valueSql . LastIndexOf ( '`' ) != - 1 && ! valueSql . Trim ( ) . EndsWith ( ")" , StringComparison . InvariantCulture ) && valueSql . Substring ( 0 , valueSql . LastIndexOf ( '`' ) ) . EndsWith ( " AS " , StringComparison . InvariantCulture ) )
1163+ if ( valueSql . LastIndexOf ( '`' ) != - 1 && ! valueSql . Trim ( ) . EndsWith ( ")" , StringComparison . InvariantCulture ) && valueSql . Substring ( 0 , valueSql . LastIndexOf ( '`' ) ) . EndsWith ( " AS " , StringComparison . InvariantCulture ) )
11531164 {
11541165 valueSql = valueSql. Substring ( 0 , valueSql . LastIndexOf ( '`' ) - 4 ) ;
11551166 }
@@ -1297,13 +1308,13 @@ public Dictionary<string, object> ResolveUpdateFromQueryDictValues<T>(Expression
12971308 {
12981309 if ( constantExpression . Value == null )
12991310 {
1300- value = new NullValue( ) { Type = constantExpression. Type } ;
1311+ value = new NullValue( ) { Type = constantExpression. Type } ;
13011312 }
13021313 else
13031314 {
13041315 value = constantExpression . Value ;
13051316 }
1306-
1317+
13071318 }
13081319 else
13091320 {
0 commit comments