RepoDB: Question: OrderBy not working, sqlite? (F#)
[<CLIMutable>]
type CommandEntity =
{ Id: Nullable<int>
AggregateId: Guid
CommandId: Guid
CausationId: Guid
CorrelationId: Guid
CommandPayload: string
PayloadType: string
QueueName: string
ExpectedVersion: Nullable<int64>
ProcessId: obj
``Timestamp Utc``: Nullable<DateTime> }
SqLiteBootstrap.Initialize()
RepoDb.Converter.ConversionType <- ConversionType.Automatic
FluentMapper.Entity<CommandEntity>().Table("CommandEntity")
|> ignore
let getAll () =
let orderBy = [| OrderField("ExpectedVersion", Order.Descending) |]
let commands = ctx.Query<CommandEntity>(fun e -> e.Id = Nullable(19), orderBy=orderBy )
yields the following:
Unhandled exception. System.InvalidOperationException: No mapping exists from object type Db+Fn+commands@80 to a known managed provider native type.
at Microsoft.Data.Sqlite.SqliteValueBinder.Bind()
at Microsoft.Data.Sqlite.SqliteParameter.Bind(sqlite3_stmt stmt)
at Microsoft.Data.Sqlite.SqliteParameterCollection.Bind(sqlite3_stmt stmt)
at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at RepoDb.DbConnectionExtension.ExecuteQueryInternal[TEntity](IDbConnection connection, String commandText, Object param, Nullable`1 commandType, Nullable`1 commandTimeout, IDbTransaction transaction, Boolean skipCommandArrayParametersCheck)
at RepoDb.DbConnectionExtension.QueryInternalBase[TEntity](IDbConnection connection, IEnumerable`1 fields, QueryGroup where, IEnumerable`1 orderBy, Nullable`1 top, String hints, String cacheKey, Int32 cacheItemExpiration, Nullable`1 commandTimeout, IDbTransaction transaction, ICache cache, ITrace trace, IStatementBuilder statementBuilder)
at RepoDb.DbConnectionExtension.QueryInternal[TEntity](IDbConnection connection, QueryGroup where, IEnumerable`1 orderBy, Nullable`1 top, String hints, String cacheKey, Int32 cacheItemExpiration, Nullable`1 commandTimeout, IDbTransaction transaction, ICache cache, ITrace trace, IStatementBuilder statementBuilder)
at RepoDb.DbConnectionExtension.Query[TEntity](IDbConnection connection, QueryGroup where, IEnumerable`1 orderBy, Nullable`1 top, String hints, String cacheKey, Int32 cacheItemExpiration, Nullable`1 commandTimeout, IDbTransaction transaction, ICache cache, ITrace trace, IStatementBuilder statementBuilder)
at RepoDb.DbConnectionExtension.Query[TEntity](IDbConnection connection, Object whereOrPrimaryKey, IEnumerable`1 orderBy, Nullable`1 top, String hints, String cacheKey, Int32 cacheItemExpiration, Nullable`1 commandTimeout, IDbTransaction transaction, ICache cache, ITrace trace, IStatementBuilder statementBuilder)
at Db.Fn.getAll() in /Users/swoorup.joshi/RiderProjects/Playground/Playground/Db.fs:line 79
RepoDb (1.11.6) RepoDb.SqLite (1.0.16)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (17 by maintainers)
Wow it appears to work, if you braces around
funit works. Very subtle.It is actually working in
QueryAllbut notQuery. I will look at this one then.@mikependon
Playground.zip
Instructions:
dotnet tool restoredotnet paket installdotnet migrondi up// test database must existsdotnet watch runinside the playground project.Same issue with postgres:
It is supported, here is the builder. Though, there is no integration test pointed specifically for OrderBy in the SqLite solutions, but it is fully covered by the Core.
Give me time to investigate this.