dotnetcore / FreeSql

🦄 .NET aot orm, C# orm, VB.NET orm, Mysql orm, Postgresql orm, SqlServer orm, Oracle orm, Sqlite orm, Firebird orm, 达梦 orm, 人大金仓 orm, 神通 orm, 翰高 orm, 南大通用 orm, 虚谷 orm, 国产 orm, Clickhouse orm, QuestDB orm, MsAccess orm.
http://freesql.net
MIT License
3.99k stars 842 forks source link

NativeAOT的Repository模式下更新失败 #1771

Open startewho opened 1 month ago

startewho commented 1 month ago

使用的https://github.com/2881099/aot_test 这里的例子 添加了FreeSql.Repository包.测试代码如下

  Console.WriteLine($"Rep模式");

    var rep = fsql.GetGuidRepository<TaskInfo>();

    fsql.Insert(data).ExecuteAffrows();

    var dbdata = fsql.Select<TaskInfo>().Where(a => a.Round == 0).First();
    dbdata.CurrentRound = -1;
    rep.Update(dbdata);

  Console.WriteLine($"更新完成");

数据库版本

sqlite,mysql

安装的Nuget包

3.2.820

.net framework/. net core? 及具体版本

.net8.0

出错结果:

Unhandled Exception: System.InvalidOperationException: The binary operator Equal is not defined for the types 'System.Reflection.Runtime.TypeInfos.RuntimeArrayTypeInfo' and 'System.Reflection.Runtime.TypeInfos.NativeFormat.NativeFormatRuntimeNamedTypeInfo'.
   at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType, String, Expression, Expression, Boolean) + 0x26b
   at System.Linq.Expressions.Expression.Equal(Expression, Expression, Boolean, MethodInfo) + 0x63
   at FreeSql.Internal.Utils.<GetDataReaderValueBlockExpression>g__LocalFuncGetExpression|67_0(Boolean, Utils.<>c__DisplayClass67_0&) + 0x36f2
   at FreeSql.Internal.Utils.<GetDataReaderValueBlockExpression>g__LocalFuncGetExpression|67_0(Boolean, Utils.<>c__DisplayClass67_0&) + 0x6db
   at FreeSql.Internal.Utils.GetDataReaderValueBlockExpression(Type, Expression) + 0x18d
   at FreeSql.DbContext.<>c__DisplayClass67_0.<FlushCommand>b__5(String methodName) + 0x1ac
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2) + 0xa4
   at FreeSql.DbContext.<>c__DisplayClass67_0.<FlushCommand>g__dbsetBatch|0(String) + 0xab
   at FreeSql.DbContext.<>c__DisplayClass67_0.<FlushCommand>g__funcUpdate|3(Boolean) + 0x20
   at FreeSql.DbContext.FlushCommand() + 0x2ce
   at FreeSql.RepositoryDbContext.SaveChanges() + 0x10
   at FreeSql.BaseRepository`1.Update(TEntity) + 0x33
   at Program.<Main>$(String[] args) + 0x16ce
   at orm_freesql!<BaseAddress>+0x833c03

最小复现项目

orm_freesql.zip