Fix EF Core global query filter problem on .netcore3.0

pull/1810/head
Halil İbrahim Kalkan 5 years ago
parent a52ba7787d
commit 0af88bc52d

@ -258,14 +258,14 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public virtual TEntity Find(TKey id, bool includeDetails = true)
{
return includeDetails
? WithDetails().FirstOrDefault(EntityHelper.CreateEqualityExpressionForId<TEntity, TKey>(id))
? WithDetails().FirstOrDefault(e => e.Id.Equals(id))
: DbSet.Find(id);
}
public virtual async Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return includeDetails
? await WithDetails().FirstOrDefaultAsync(EntityHelper.CreateEqualityExpressionForId<TEntity, TKey>(id), GetCancellationToken(cancellationToken))
? await WithDetails().FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken))
: await DbSet.FindAsync(new object[] { id }, GetCancellationToken(cancellationToken));
}

@ -493,12 +493,12 @@ namespace Volo.Abp.EntityFrameworkCore
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
{
expression = e => !IsSoftDeleteFilterEnabled || !((ISoftDelete) e).IsDeleted;
expression = e => !IsSoftDeleteFilterEnabled || !EF.Property<bool>(e, "IsDeleted");
}
if (typeof(IMultiTenant).IsAssignableFrom(typeof(TEntity)))
{
Expression<Func<TEntity, bool>> multiTenantFilter = e => !IsMultiTenantFilterEnabled || ((IMultiTenant) e).TenantId == CurrentTenantId;
Expression<Func<TEntity, bool>> multiTenantFilter = e => !IsMultiTenantFilterEnabled || EF.Property<Guid>(e, "TenantId") == CurrentTenantId;
expression = expression == null ? multiTenantFilter : CombineExpressions(expression, multiTenantFilter);
}

@ -86,7 +86,7 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb
public virtual TEntity Find(TKey id, bool includeDetails = true)
{
return GetQueryable().FirstOrDefault(EntityHelper.CreateEqualityExpressionForId<TEntity, TKey>(id));
return GetQueryable().FirstOrDefault(e => e.Id.Equals(id));
}
public virtual TEntity Get(TKey id, bool includeDetails = true)

Loading…
Cancel
Save