jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
856 stars 145 forks source link

NullReferenceException calling InsertAsync #495

Closed elandev closed 4 months ago

elandev commented 1 year ago

Describe the bug

Get a NullReferenceExceptionwhen calling InsertAsync with a stored procedure. See exception below.

When I use ExecuteAsyncwith the same stored procedure it works.

Object reference not set to an instance of an object.
   at Insight.Database.DbSerializationRule.EvaluateRules(ClassPropInfo prop)
   at Insight.Database.ColumnMapping.MapParameter(Type type, IDbCommand command, IDataParameter parameter)
   at System.Linq.Enumerable.SelectListIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Insight.Database.CodeGenerator.DbParameterGenerator.CreateClassInputParameterGenerator(IDbCommand command, Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Insight.Database.DBCommandExtensions.AddParameters(IDbCommand cmd, Object parameters)
   at Insight.Database.DBConnectionExtensions.CreateCommand(IDbConnection connection, String sql, Object parameters, CommandType commandType, Nullable`1 commandTimeout, IDbTransaction transaction)
   at Insight.Database.DBConnectionExtensions.<>c__DisplayClass21_0`1.<InsertAsync>b__0(IDbConnection c)
   at Insight.Database.DBConnectionExtensions.<ExecuteAsyncAndAutoClose>d__36`1.MoveNext()
   at TestMySql.Program.<InsertData>d__7.MoveNext() in C:\Dev\src\Scratch\TestMySqlInsert\Program.cs:line 101

Steps to reproduce

  1. Load the attached project with Visual Studio 2022.
  2. Set up MariaDB as the database (10.11.2-MariaDB).
  3. Edit the server, database name and credentials for the connection string.
  4. Restore Nuget packages and build the solution.
  5. Run the project.

Expected behavior

I expected the InsertAsyncto work and return the auto-incremented ID.

TestMySqlInsert.zip

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

elandev commented 1 year ago

This issue still exists. Is there an update on this?

stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jonwagner commented 4 months ago

Unfortunately, we can't accept project zip files as reproduction cases. Please paste sufficient code to reproduce here, or submit a PR with a failing test case.