Search code examples
c#.netsqliteasp.net-coreblob

How to use SQLiteBlob when rowId is not an integer?


How can SQLLiteBlob be used oder replace by another method when the rowId is a string? Here the sample code.

    public void WriteContent(Stream contentStream, string table, string rowId)
    {
        // ToDo : Find Solution for Writing to Blob as RowId is no more an integer
        using var writeStream = new SqliteBlob(this.executionContext.GetConnection(), table, ColumnName, rowId);
        contentStream.CopyTo(writeStream);
    }

Alternative way to use the method with a string or an alternative way to implement.


Solution

  • You better make it integer.
    Rowid can only be integer. If not, means you are using table"without rowid" . https://www.sqlite.org/lang_createtable.html#rowid

    Without rowid, Blob I/O wouldn't work.
    https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/blob-io
    https://www.sqlite.org/c3ref/blob_open.html enter image description here