Giter VIP home page Giter VIP logo

Comments (12)

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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.

thanhpegasus avatar thanhpegasus commented on June 12, 2024

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.

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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.

thanhpegasus avatar thanhpegasus commented on June 12, 2024

Hi Jonathan,

That's fine with me but do you have any ETA for the implementation.

Kind and Regards,

from entityframework-classic.

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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.

thanhpegasus avatar thanhpegasus commented on June 12, 2024

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.

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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.

thanhpegasus avatar thanhpegasus commented on June 12, 2024

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.

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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.

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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.

thanhpegasus avatar thanhpegasus commented on June 12, 2024

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.

JonathanMagnan avatar JonathanMagnan commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.