Fioenix
Fioenix

Reputation: 39

Get all deleted record

I'm looking for a way to get all records where deleted is set to true on a particular table. How might I accomplish this?

Note: Using auto-generated class by SubSonic. Not T-SQL.

Upvotes: 0

Views: 186

Answers (3)

Tadmas
Tadmas

Reputation: 6368

I've never heard of SubSonic before, but a quick Google search turned up: Select Queries in SubSonic.

So, using that page as a guide, it sounds like you'd be able to write your query as:

FooCollection deletedFoos = // use the generated collection class
    DB.Select().From("FooTable") // table name goes here
        .Where("deleted").IsEqualTo(true) // might need 1, depends on database?
        .ExecuteAsCollection<FooCollection>(); // should match the type above

Upvotes: 2

Dave Neeley
Dave Neeley

Reputation: 3635

The auto-generated SubSonic classes don't support querying logical deletes. But you can do this (version 2.1/2.2 syntax):

public partial class TableClassCollection
{

    public TableClassCollection LoadAll(bool suppressLogicalDeletes)
    {

          SubSonic.SqlQuery q = new SubSonic.Select(TableClass.Schema)
              .From(TableClass.Schema);

          if (suppressLogicalDeletes)
          {
              q.Where(TableClass.DeletedColumn).IsEqualTo(false);
          }

          return q.ExecuteAsCollection<TableClassCollection>();
      }

}

More examples at subsonicproject.com

Upvotes: 2

x0n
x0n

Reputation: 52450

not a lot of detail in your question, but assuming there's a column named "deleted," it would look something like this:

select * from tableName where deleted = true

Upvotes: -1

Related Questions