Question

In subsonic 2 we could do this:

public static void DeleteTable(SubSonic.TableSchema.Table table)
{
     new Delete().From(table).Execute();
}

How can we do the same thing in v3? I can only seem to find documentation about using generics to target a specific table in the database...I want to be able to use it with a parameter as above.

Thanks

Was it helpful?

Solution

I got it. This seems to do the trick:

public static void DeleteTable(DatabaseTable table)
{
     new Delete<object>(table, table.Provider).Execute();
}

OTHER TIPS

You use the SimpleRepository.DeleteMany method somehow like this

var repo = new SimpleRepository("ConnectionString");
repo.DeleteMany<YourClass>(x => true);

Or (after reading your comment) something like that

public static void DeleteTable(DatabaseTable table)
{
    new SubSonic.Query.Delete<object>(table, ProviderFactory.GetProvider());
}

The generic type "object" is used because Delete wants a Type passed, which is not used in case we create it using a table and provider.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top