Update part of a record's composite primary key

Hi,

I’d like to update one of two values in a record’s composite primary key…

                await Db.UpdateOnlyAsync(() =>
                        new dsMapping.TargetTable
                        {
                            SourceSchemaName = table.SourceSchemaName,
                            SourceTableName = table.SourceTableName
                        },
                    where: t => string.Equals(t.SourceSchemaName, table.SourceSchemaName,
                                    StringComparison.OrdinalIgnoreCase) &&
                                string.Equals(t.SourceTableName, table.SourceTableName,
                                    StringComparison.OrdinalIgnoreCase));

Where TargetTable’s SourceSchemaName and SourceTableName columns comprise the primary key.

Data integrity is avoided through the other database changes, so there is no concern of duplicating a clustered index value.

It doesn’t look like any of OrmLite’s Update apis will allow this - is that correct?

As a primary limitation OrmLite doesn’t support multiple primary keys.

You also can’t just use any undocumented function like string.Equals(), all expressions need to translated to server side RDBMS agnostic SQL, so if there’s no example or documentation of using a function within a typed SQL Expression it’s not going to be supported.

await Db.UpdateOnlyAsync(() =>
      new dsMapping.TargetTable {
          SourceSchemaName = table.SourceSchemaName,
          SourceTableName = table.SourceTableName
      },
  where: t => t.SourceSchemaName == table.SourceSchemaName &&
              t.SourceTableName == table.SourceTableName);

Ah Ok, thanks. I hadn’t seen that documentation page before but it makes sense. I’m aware SqlLite doesn’t support composite keys.