Troubleshooting — EricksonLopez.SqlBuilder
Common Roslyn analyzer (EricksonLopez.SqlBuilder.Analyzers) and Native AOT compiler errors.
Roslyn Analyzer Diagnostics (ESQL005, ESQL007, ESQL011)
Section titled “Roslyn Analyzer Diagnostics (ESQL005, ESQL007, ESQL011)”ESQL005([SqlEntity]must bepartial):SqlBuilder.SourceGeneratorscannot emitGetReaderParser()orIStaticEntityMetadata<T>unless the target entity class is declaredpartial.ESQL007(UnindexedOrderBy/OrderByDescendingproperty): Annotate indexed sort keys (such asId) with[Indexed]fromEricksonLopez.SqlBuilder.Annotationsto clearESQL007.ESQL011(Sql.Raw(string)): Always bindFormattableString(FormattableString sql = $"..."; Sql.Raw(sql);) instead of raw strings so interpolated values become SQL parameters.
IL2026 / IL3050 on AotQueryAsync & Missing Compiler Registration
Section titled “IL2026 / IL3050 on AotQueryAsync & Missing Compiler Registration”- AOT warning on
AotQueryAsync(ISqlQuery, ...): Expression-tree compilation carries[RequiresDynamicCode]/[RequiresUnreferencedCode]. Pass a pre-compiledSqlResult(compiler.Compile(rawQuery)) toAotQueryAsync(SqlResult, mapper)on strict Native AOT hot paths. InvalidOperationExceptiononDelete<T>()or Dapper:Delete<T>()rejects unbounded deletes lacking.Where(...), andEricksonLopez.SqlBuilder.DapperrequiresDapperExtensions.RegisterCompiler<TConnection>(...)before executing queries.