I'm trying to add some custom data filtering in CreateFilterExpression method.
Expression<Func<BookingEntity, bool>> entityTypes = e =>
e.Type == AccountAssociationType.Shipper
&& ((e.AccountId == 4958 && e.Booking.AccountId == 2) || (e.AccountId == 4969 && e.Booking.AccountId == 3));
I've already built the condition using PredicateBuilder.
Expression<Func<BookingEntity, bool>> entityTypesPredicate = PredicateBuilder.New<BookingEntity>(true);
entityTypesPredicate = entityTypesPredicate.And(w => w.Type == AccountAssociationType.Shipper);
Expression<Func<BookingEntity, bool>> predicateAssociations = PredicateBuilder.New<BookingEntity>(true);
foreach (var a in AvailableContactAssociations)
predicateAssociations = predicateAssociations.Or(w => w.AccountId == a.Key && w.Booking.AccountId == a.Value);
entityTypesPredicate = entityTypesPredicate.And(predicateAssociations);
Since entityTypesPredicate is built only when the application starts, how can use it every time I want to use it while building the FilterExpression?
AvailableContactAssociations looks like:
protected virtual List<ContactAssociation> AvailableContactAssociations
Any tip? What am I missing?
Thanks!
I'm having an error while loading my app using AWS Beanstalk. The error: System.UnauthorizedAccessException: Access to the path 'C:\inetpub\AspNetCoreWebApps\app\tempkey.jwk' is denied.
Any tip? Thanks.
Hi all, I'm trying to access TenantManager in BackgroundJob. But i'm getting is disposed error.
System.ObjectDisposedException Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'CustomerHubDbContext'.
System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'CustomerHubDbContext'. at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed() at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() at Microsoft.EntityFrameworkCore.DbContext.get_Model() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_EntityType() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.get_EntityQueryable() at Microsoft.EntityFrameworkCore.Internal.InternalDbSet1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator() at CustomerHub.Jobs.SyncBusinessPartners.Execute(Int32 x) in C:_GIT\SyncBusinessPartners.cs:line 42
Below the code of SyncBusinessPartners Job (highlighted the row in error - line42)
public class SyncBusinessPartners : BackgroundJob<int>, ITransientDependency
{
private readonly TenantManager _tenantManager;
private readonly IAbpSession _abpSession;
private readonly UserManager _userManager;
private readonly ILogger<SyncBusinessPartners> _logger;
public SyncBusinessPartners(
TenantManager tenantManager,
IAbpSession abpSession,
UserManager userManager,
ILogger<SyncBusinessPartners> logger
)
{
_tenantManager = tenantManager;
_abpSession = abpSession;
_userManager = userManager;
_logger = logger;
LocalizationSourceName = CustomerHubConsts.LocalizationSourceName;
}
public override void Execute(int x)
{
_logger.LogInformation(L("JobExecutionStarted", args: $"{nameof(SyncBusinessPartners)}"));
**foreach (var t in _tenantManager.Tenants)**
{
var admin = _userManager.FindByNameAsync("admin").Result;
}
_logger.LogInformation(L("JobExecutionFinished", args: nameof(DocumentDto)));
}
}
I've tried to use UnitOfWork attribute on my method Execute. But when i do this, all the information to be synced in bulk and not iteration by iteration.
Thanks in advance!
How can i add a new SettingScope? I need some settings to be linked to User and their Companies or Working Sites. When retrieved they should fallback up to Company starting at User level.
Do i need to create a specific Setting entity? Also a new SettingManager?
Any tip? Thanks
Hi, I'm trying to built an "global filter", like a scope, to filter all my queries on entities that depends on it. Mix between Tenant and Localization.
I've already have the selection. It will store the value in Settings entity, using SettingManager.
My questions are:
Thanks in advance.