Git Product home page Git Product logo

ef-core-soft-delete's Introduction

Entity Framework Core 3x/5 soft deletables

This repository contains code to show how to use HasQueryFilter to provide soft deletes against any model which implements a specific Interface.

Microsoft TechNet article

screenshot

Setup

  • Run the following script to create the database and populate tables.
  • From Visual Studio solution explorer select Restore Nuget packages.
  • Ensure WindowsFrontEnd or WindowsFrontEndCore5 is the startup project.
  • Build the solution
  • Run

EntityLibrary Requires

  • Microsoft Framework 4.7.2 or higher
  • Microsoft Visual 2017 or higher
  • Microsoft SQL-Server 2012 or higher

EntityLibraryCore5 Requires

  • Microsoft Framework .NET Core 5, C# 9
  • Microsoft Visual 2019 or higher
  • Microsoft SQL-Server 2012 or higher

private void RemoveCurrentSupplierButton_Click(object sender, EventArgs e)
{

    var currentSupplier = _supplierBindingSource.Current as Suppliers;

    if (!Question($"Remove {currentSupplier.CompanyName}")) return;

    using (var context = new NorthwindContext())
    {
        context.Entry(currentSupplier).State = EntityState.Deleted;
        context.SaveChanges();
        _supplierBindingSource.RemoveCurrent();
    }
}

ef-core-soft-delete's People

Contributors

karenpayneoregon avatar

Watchers

 avatar  avatar

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.