Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "aaron"

Could you be more specific with this line:

repository.As<EfCoreRepositoryBase<MyDbContext, AnnouncementEntity>>().Table.Attach(announce);

Btw im not using EfCore.

Please specify that in future questions.

And simply remove Core.

my _announcementRepo doesnt have "As" method.

Add this using directive:

using Abp.Extensions;

You can hold Ctrl + . to fix such reference issues.

To do that, you should attach the entity.

// Create new stub with correct id and attach to context.
var announce = new AnnouncementEntity { Id = input.Id };
repository.As<EfCoreRepositoryBase<MyDbContext, AnnouncementEntity>>().Table.Attach(announce);

// Now the entity is being tracked by EF, update required properties.
announce.Header = input.Header;

// EF knows only to update the properties specified above.
_unitOfWorkManager.Current.SaveChanges();

Okay, what's probably happening is:

  • your stored procedure removes the permissions, but
  • the role permission cache says the permissions are still there, so
  • the role permissions don't get re-added. You can inject ICacheManager and clear the cache:
private async Task RemoveOldgarntedPermissionAsync(int id)
{
    var oldpermessionsToBeDeleted = await _sysobjectCustomRepo.RemoveGrantedPermessionsForRole(id);
    _cacheManager.GetRolePermissionCache().Clear();
}

Try calling SaveChanges in RemoveOldgarntedPermissionAsync.

Answer

Please post a new topic. Remember to state which version you upgraded from and to.

What are the current and expected behaviors? Give an example with before and after permissions.

What do you mean by it didn't work?

Understand. I just feel the "-2147482647" weird.

So did @hikalkan on Jul 23, 2016 ;)

It is by design. InsertAsync only does Table.Add(entity), which avoids the overhead of calling SaveChanges.

You can use InsertAndGetIdAsync or call SaveChanges:

// 1
var id = await _repository.InsertAndGetIdAsync(obj); // New id

// 2
await _repository.InsertAsync(obj);
_unitOfWorkManager.Current.SaveChanges();
var id = obj.Id; // New id

Users would be assigned permissions through roles, not directly. You can check:

var grantedPermissions = UserManager.GetGrantedPermissionsAsync(user);
Showing 1301 to 1310 of 1543 entries