Also, will have the same problem with this method.
public static int CreateCompositeIndex<T>(this IDbConnection db, string indexName,
params Expression<Func<T, object>>[] columns)
{
var tableName = GetTableName<T>(db);
var colNames = new List<string>();
foreach (var col in columns)
{
switch (col.Body)
{
case MemberExpression mem:
colNames.Add(mem.Member.Name);
break;
case UnaryExpression un:
if (un.Operand is MemberExpression mem2)
{
colNames.Add(mem2.Member.Name);
}
break;
}
}
return db.ExecuteSql($"CREATE UNIQUE INDEX {indexName} on {tableName} ({colNames.Join(", ")})");
}
Q: Do you have built-in support for these extension methods??
It’s not clear what the Issue is, you can have multiple Dialects in the same project, for example the ServiceStack.OrmLite.Tests project has all of them.
But if you do have a library that references the concrete Dialect Providers, that library always needs references to the concrete providers. If you don’t want the concrete dependency check against something that doesn’t require a concrete dependency like OrmLiteConfig.DialectProvider.GetType().Name instead.
OrmLite does have a [CompositeIndex] attribute which you can annotate on your Table classes to create composite indexes.