soft-delete

Entity Framework Code First Soft Delete Lazy Loading

旧街凉风 提交于 2019-12-02 07:06:16
So I'm using Entity Framework Code First (so no .edmx) I have a base entity class with a bool IsEnabled to do soft delete's I am using repository pattern so all queries against the repository can be filtered out with IsEnabled. However any time I use the repository to get an MyType which is IsEnabled, Lazy Loading MyType.Items may mean that Items could be not enabled. Is there a way, perhaps with EF Fluent to describe how to do filtering on tables? Update: If I have a Dbset public class UnitOfWork : DbContext { private IDbSet<MyObj> _MyObj; public IDbSet<MyObj> MyObjs { get { return _MyObj ??

Neo4j: implementing soft delete with optional relationships

杀马特。学长 韩版系。学妹 提交于 2019-12-02 07:04:44
I'm trying to implement a soft delete in Neo4j. The graph described in Cypher from Alice's viewpoint is as such: (clyde:User)<-[:FOLLOWS]-(alice:User)-[:LIKES]->(bob:User) Instead of actually deleting a node and its relationships, I'm changing its label so it can no longer be looked up directly, i.e. dropping its User label and adding a _User label (notice the underscore) replacing its relationships so it can't be reached anymore by my normal queries, e.g. deleting its :FOLLOWS relationships and replacing it with :_FOLLOWS relationships. So this is basically the equivalent of moving a row to

Entity Framework soft delete implementation using database interceptor not working

半腔热情 提交于 2019-12-01 00:27:15
问题 I have implemented a database soft delete (a boolean flag that marks entries as deleted) using the following tutorial: http://www.codeguru.com/csharp/csharp/soft-deleting-entities-cleanly-using-entity-framework-6-interceptors.html It seems to me a very good implementation because once set up soft delete is applied to a model simply by adding a [SoftDelete("IsDeleted")] annotation. Problem is so far it is not working. The source appears to be reliable, and they even published an example of

Symfony2 SoftDeleteable not working on QueryBuilder Delete

隐身守侯 提交于 2019-11-30 22:08:19
Softdelete behavior works fine on execute delete statement via the entity manager as the following code: $entity = $this->em->getRepository('Users')->find(7); $this->em->remove($entity); $this->em->flush(); but when execute the same functionality via QueryBuilder hard delete will execute on database $qb = $this->em->createQueryBuilder(); $qb->delete('Users', 'p'); $qb->where($qb->expr()->eq('p.id', ':id')); $qb->setParameters(array("id" => 7)); $result = $qb->getQuery()->getResult(); How can I allow softdelete in all cases either via entity manager or query builder If you use DQL then you have

Symfony2 SoftDeleteable not working on QueryBuilder Delete

纵然是瞬间 提交于 2019-11-30 17:53:19
问题 Softdelete behavior works fine on execute delete statement via the entity manager as the following code: $entity = $this->em->getRepository('Users')->find(7); $this->em->remove($entity); $this->em->flush(); but when execute the same functionality via QueryBuilder hard delete will execute on database $qb = $this->em->createQueryBuilder(); $qb->delete('Users', 'p'); $qb->where($qb->expr()->eq('p.id', ':id')); $qb->setParameters(array("id" => 7)); $result = $qb->getQuery()->getResult(); How can

Hibernate: Overwrite sql-delete with inheritace

亡梦爱人 提交于 2019-11-29 05:03:01
I have an entity A and B extends A and try to have a soft-delete with joined inheritance strategy. @Entity @Inheritance(strategy = InheritanceType.JOINED) @SQLDelete("UPDATE A SET deleted = 1 WHERE id = ?") A { @Id long id; boolean deleted; } @Entity B extends A {} It seems that Hibernate properly sets the table A to deleted = 1 , but also deletes the whole entry from table B . I would, of course, like to preserve this entry. Any ideas on that? I'm using Hibernate 3.5.5 and annotation-based entity definition. Tried Hibernate 3.6.2 as well. slipset You'd want to create a DeleteEventListener as

Soft Delete Cascading with Laravel 5.2

被刻印的时光 ゝ 提交于 2019-11-29 02:53:34
问题 I'm trying to implement soft deleting in Laravel. Here are my relationships Tournament ( hasMany ) CategoryTournament (hasOne) CategorySettings Tournament ( hasMany ) CategoryTournament (belongsToMany) CategoryTournamentUser So, I used this answer that help me a lot Now, when I SoftDelete a Tournament, all CategoryTournaments related are also deleted. But then, I tried to apply it recursively, so I wrote the same code in CategoryTournament Model: static::deleting(function($categoryTournament)

Disable SoftDelete for AbpUserRole

自闭症网瘾萝莉.ら 提交于 2019-11-28 13:12:51
By default, the AbpUserRole and AbpRole implement ISoftDelete . Is it possible to disable it? I tried to do this: [AbpAuthorize(AppPermissions.Pages_Administration_Roles_Delete)] public async Task DeleteRole(EntityDto input) { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete)) { var role = await _roleManager.GetRoleByIdAsync(input.Id); var users = await UserManager.GetUsersInRoleAsync(role.Name); foreach (var user in users) { CheckErrors(await UserManager.RemoveFromRoleAsync(user, role.Name)); } CheckErrors(await _roleManager.DeleteAsync(role)); } } Although the filter is

ExpressionVisitor soft delete

一笑奈何 提交于 2019-11-28 11:46:50
We're having some issues implementing soft delete functionality with entity framework. The idea is to use a repository which is aware of the EF context. On the level of the repository we implemented a plugin system, these plugins get executed whenever an action is done on the repository. For example when we call Repository.GetQuery<Relation>() the plugins get executed. One of the plugins is a LogicalDeletePlugin , this plugin should add a Where(x => x.IsDeleted) statement to each table which is in the select. The idea was to implement this IsDeleted plugin using an ExpressionVisitor which

Hibernate: how to fetch only not-logically deleted objects

女生的网名这么多〃 提交于 2019-11-28 08:03:19
问题 Nearly every table in our database has a FK to the Auditing table which logs created, updated and deleted status (date and username). We mapped the auditing table to the Auditing class and use it like this: @MappedSuperclass public class BusinessObject extends DataObject { private static final long serialVersionUID = -1147811010395941150L; @OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }) @JoinColumn(name = "AUD_ID") private AuditingObject auditing; ... As you'd expect, nearly