Skip to content

Commit a3f3cfd

Browse files
author
zzzprojects
committed
Fix
Fix
1 parent 2b60fdd commit a3f3cfd

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

src/shared/Z.EF.Plus.Audit.Shared/AuditEntryState.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public enum AuditEntryState
2929
RelationshipAdded,
3030

3131
/// <summary>An enum constant representing the relationship deleted option.</summary>
32-
RelationshipDeleted
32+
RelationshipDeleted,
33+
34+
/// <summary>An enum constant representing the entity current option.</summary>
35+
EntityCurrent
3336
}
3437
}

src/shared/Z.EF.Plus.BatchDelete.Shared/BatchDelete.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
380380
// GET command
381381
var command = query.Context.CreateStoreCommand();
382382

383+
bool isPostgreSql = command.GetType().Name == "NpgsqlCommand";
383384
bool isMySql = command.GetType().FullName.Contains("MySql");
384385
var isSqlCe = command.GetType().Name == "SqlCeCommand";
385386
var isOracle = command.GetType().Namespace.Contains("Oracle");
@@ -441,7 +442,7 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
441442
}
442443

443444
// GET command text template
444-
var commandTextTemplate = command.GetType().Name == "NpgsqlCommand" ?
445+
var commandTextTemplate = isPostgreSql ?
445446
CommandTextPostgreSQLTemplate :
446447
isOracle ?
447448
CommandTextOracleTemplate :
@@ -465,6 +466,11 @@ internal DbCommand CreateCommand<T>(ObjectQuery query, SchemaEntityType<T> entit
465466
return null;
466467
}
467468

469+
if (isPostgreSql && customQuery.Item1.EndsWith("WHERE TRUE = FALSE", StringComparison.InvariantCultureIgnoreCase))
470+
{
471+
return null;
472+
}
473+
468474
var querySelect = customQuery.Item1;
469475

470476
// GET primary key join

src/shared/Z.EF.Plus.QueryFilterInterceptor.Shared/QueryFilterInterceptorDbCommandTree.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
using System;
22
using System.Data.Entity.Core.Common.CommandTrees;
3+
using System.Data.Entity.Core.Metadata.Edm;
34
using System.Data.Entity.Infrastructure.Interception;
45
using System.Linq;
6+
using System.Reflection;
57

68
namespace Z.EntityFramework.Plus
79
{
810
/// <summary>A query interceptor filter database command tree.</summary>
911
public class QueryFilterInterceptorDbCommandTree : IDbCommandTreeInterceptor
1012
{
13+
public static ConstructorInfo DbQueryCommandTreeConstructor = typeof(DbQueryCommandTree).GetConstructor(new Type[] { typeof(MetadataWorkspace), typeof(DataSpace), typeof(DbExpression), typeof(bool), typeof(bool) });
1114
/// <summary>
1215
/// This method is called after a new
1316
/// <see cref="T:System.Data.Entity.Core.Common.CommandTrees.DbCommandTree" /> has been created.
@@ -80,9 +83,19 @@ public void TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
8083
};
8184

8285
var newQuery = queryFiltered.Accept(visitor);
83-
86+
8487
// CREATE a new Query
85-
var commandTree = new DbQueryCommandTree(dbQueryCommandTree.MetadataWorkspace, dbQueryCommandTree.DataSpace, newQuery, true);
88+
DbQueryCommandTree commandTree;
89+
if (DbQueryCommandTreeConstructor != null)
90+
{
91+
commandTree = (DbQueryCommandTree)DbQueryCommandTreeConstructor.Invoke(new object[] { dbQueryCommandTree.MetadataWorkspace, dbQueryCommandTree.DataSpace, newQuery, true, interceptionContext.OriginalResult.DataSpace != DataSpace.CSpace });
92+
}
93+
else
94+
{
95+
commandTree = new DbQueryCommandTree(dbQueryCommandTree.MetadataWorkspace, dbQueryCommandTree.DataSpace, newQuery, true);
96+
97+
}
98+
8699
interceptionContext.Result = commandTree;
87100
}
88101
}

src/shared/Z.EF.Plus._Core.Shared/EFCore/GetStateManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// More projects: http://www.zzzprojects.com/
66
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
77

8-
#if FULL
8+
#if FULL || QUERY_FUTURE
99
#if EFCORE
1010
using System.Reflection;
1111
using Microsoft.EntityFrameworkCore.ChangeTracking;

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.6.19
1+
v1.6.20

0 commit comments

Comments
 (0)