开发者

Subsonic Delete With Fluent Query Tool

开发者_运维知识库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


I got it. This seems to do the trick:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜