EM0
EM0

Reputation: 6337

Drop and re-create index in ServiceStack OrmLite

I have some MSSQL tables created by ServiceStack.OrmLite and I'd like to programmatically change the types of some some columns or perhaps drop and re-create some of them (with different types). The problem is that some of them may be used in indexes (also created by OrmLite from [Index]/[CompositeIndex] attributes). Is there an easy way to ask OrmLite to drop and to create all indexes used by particular column?

I noticed there is IDbConnection.CreateIndex, but this probably won't work for composite indexes. There is also IDbConnection.DropIndex, but that requires the name of the index, which I don't have.

Upvotes: 3

Views: 599

Answers (1)

mythz
mythz

Reputation: 143349

There's no API that says "drop/re-create Indexes for a column", the only DDL APIs OrmLite offers are on the OrmLiteSchemaModifyApi class.

You'll need to use db.ExecuteSql for any other table modifications you want to perform programmatically.

Upvotes: 2

Related Questions