ToUpdateStatement missing?

I have the following helper methods used to create statements that I can batch later on:

public static string ToUpdateStatement<T>(T item)
{
    return SqlServerDialect.Provider.SqlExpression<T>().ToUpdateStatement(item);
}

public static string ToInsertStatement<T>(T item)
{
    return SqlServerDialect.Provider.ToInsertRowStatement(null, item);
}

However the ToUpdateStatement method is now missing in v4.0.60. Is there an alternative method somewhere?

We’ve had to remove these APIs after we migrated all of OrmLite to parameterized queries as the SQL is now dependent on the db parameters and is no longer self-contained into a single SQL statement.

I’ll see if I can have a look at creating an API that merges the param values into inline SQL statement.

I’ve just added support for ToInsertStatement/ToUpdateStatement in this commit.

Which now lets you use the APIs on IDbConnection or dialect provider to merge SQL params into an inline SQL statement, e.g:

var updateSql = db.ToUpdateStatement(item);
var insertSql = db.ToInsertStatement(item);

This change is available from v4.0.61 that’s now available on MyGet.

1 Like

That’s awesome thanks Demis. Much appreciated. I can get back to batching statements :slight_smile:

1 Like