Comments (12)
Hello @thanhpegasus ,
Sure we could support it,
We will think on our side about how to implement it to flag an entity as Soft Deleted
.
Do you have an idea on your side or know a library that supports it like the way you would like we do in EF Classic?
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
Ideally, we should have an interface like above
public interface ISoftDelete
{
bool IsDeleted { get; set; }
}
Then, in BulkSynchronize and BulkDelete, we can check if the entity implement ISoftDelete so we can generate sql to update the flag IsDeleted.
I hope it would help
Kind and Regards,
from entityframework-classic.
Hello @thanhpegasus ,
Thank for your feedback, we looked as well on our side and an interface was, of course, one of the proposed solutions.
To be honest, we got way too many requests this week so I do not believe we will have the time to begin this new features in the next few days but that's for sure something we will try to begin next week.
It's fine with you?
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
That's fine with me but do you have any ETA for the implementation.
Kind and Regards,
from entityframework-classic.
Hello @thanhpegasus ,
Just to let you know, I will give you an ETA on next Monday.
A lot of work is usually done during the weekend, so it will be easier to give you this information.
Do you need something also for SaveChanges
?
Is there a priority order on your side? For example, BulkUpdate
first, then SaveChanges
from entityframework-classic.
Hi Johnathan,
Please prioritize BulkUpdate
.
But I'm not sure what we can do with SaveChanges
. Normally, I just explicit set IsDeleted
flag in order to soft delete an Entity
. Can you share your idea.
Kind and Regards
from entityframework-classic.
Hello @thanhpegasus ,
Good news, our prototype currently work with BulkDelete
and SaveChanges
. I do not believe we will make it works with BulkSynchronize
due to how this method is coded.
For SaveChanges
, the idea is pretty much the same
When you perform a remove:
var list = context.SoftDeleteEntities.ToList();
list.ForEach(x => x.ColumnInt += 100);
context.SoftDeleteEntities.Remove(list[0]);
context.SaveChanges();
The item will be updated with the flag IsDeleted = 1
instead of being removed.
We will review our prototype and try to complete all the tests tomorrow. A release should definitively happen within a few days,
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
I'm very appreciate your work and EF Classic team. Please also update the document when this feature officially launched.
Kind and Regards,
from entityframework-classic.
Hello @thanhpegasus ,
The v7.0.26 has been released.
The documentation is not yet ready (we will work on it tomorrow), but the feature is already available.
Basically, it's very straightforward to use:
We added an interface IEFSoftDelete
public class SoftDeleteEntity : IEFSoftDelete
{
public int SoftDeleteEntityID { get; set; }
public int ColumnInt { get; set; }
public string ColumnString { get; set; }
public bool IsDeleted { get; set; }
}
You can specify your own interface/logic:
public EntitiesContext() : base("EntitiesContext")
{
this.Configuration.SoftDelete.Trigger<ISoftDelete>((context, entity) =>
{
entity.IsDeleted = true;
entity.DeletedAt = DateTime.Now;
});
}
Let me know if you need some help to get started, we should start the documentation about this feature tomorrow, so a lot of online examples will be soon available.
Best Regards,
Jonathan
from entityframework-classic.
Hello @thanhpegasus ,
Did you have the chance to try the Soft Delete
feature?
Is there something missing?
The documentation can be found here: https://entityframework-classic.net/soft-delete
Best Regards,
Jonathan
from entityframework-classic.
Hi Jonathan,
Sorry for late response. Unfortunately, I haven't get a chance to try SoftDelete
feature. But I will apply it on the next task.
I'll let you know if it works or something else that I can suggest.
Thanks for your
from entityframework-classic.
Hello @thanhpegasus ,
We will close this issue but if there is anything, let us know and we will re-open it.
Best Regards,
Jonathan
from entityframework-classic.
Related Issues (20)
- Type not supported yet (LazyType): sdo_geometry HOT 11
- "Cannot bind argument to parameter 'Path' because it is an empty string" when running Add-Migration HOT 9
- Include with InvalidCastException exception HOT 4
- IDbContext HOT 8
- EF6 is available for .NET Core 3+ HOT 1
- HasNoKey and Constructor with Parameters HOT 5
- Make DbMigrator constructors public HOT 4
- Link to entityframework.net HOT 3
- Count() inside string expression in Execute method HOT 4
- Creating new array inside expression string - Execute extension method HOT 8
- Error when using UpdateFromQuery on an expanded query (Linqkit) HOT 3
- DbMigrator - Problems with existing migrations HOT 6
- HierarchyId.GetAncestor method raise an unexpected exception HOT 7
- Current Values are not reset when using SoftDelete HOT 6
- this.Configuration not availalbe in .net core 6 for soft delete HOT 3
- EDMX - Unable to cast object of type ObjectQuery to DbQuery in .Include() HOT 19
- The object cannot be deleted because it was not found in the ObjectStateManager HOT 1
- IDbCommandInterceptor called multiple times on queries with .IncludeOptimizedByPath() HOT 2
- add new provider Microsoft.Data.SqlClient HOT 3
- Unable to load the specified metadata resource. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframework-classic.