databasemodel-view-controllerinformation-hiding

How can I hide data in MVC?


I’m new to MVC and am building a project in ASP.NET MVC.

In my project I don’t want to delete any saved data from my database, but hide them from the user. I look some giving status to data, but I don’t understand. What is the explanation?


Solution

  • I can explain a common way to do it. This is a quick answer using SQL Server.

    Please study SQL first before starting your project. Here is a good place to learn SQL.

    I assume the table name is "MyItems":

    1. Add another column to your table

    2. Name it as IsActive (or whatever you want)

    3. Set the data type as bit

      Enter image description here

    4. You can set either true or false for this column

      Enter image description here

    5. Write your SQL select query as:

      Select * from MyItems where IsActive=1
      

      This will give you all IsActive=true records.

      If you want to get hidden records:

      Select * from MyItems where IsActive=0