dotnetcore / dotnetcore/FreeSql
NativeAOT的Repository模式下更新失败
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 910
- PR merge metrics
- No merged PRs in 30d
Description
使用的https://github.com/2881099/aot_test 这里的例子
添加了FreeSql.Repository包.测试代码如下
```cs
Console.WriteLine($"Rep模式");
var rep = fsql.GetGuidRepository();
fsql.Insert(data).ExecuteAffrows();
var dbdata = fsql.Select().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.g__LocalFuncGetExpression|67_0(Boolean, Utils.<>c__DisplayClass67_0&) + 0x36f2
at FreeSql.Internal.Utils.g__LocalFuncGetExpression|67_0(Boolean, Utils.<>c__DisplayClass67_0&) + 0x6db
at FreeSql.Internal.Utils.GetDataReaderValueBlockExpression(Type, Expression) + 0x18d
at FreeSql.DbContext.<>c__DisplayClass67_0.b__5(String methodName) + 0x1ac
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey, Func`2) + 0xa4
at FreeSql.DbContext.<>c__DisplayClass67_0.g__dbsetBatch|0(String) + 0xab
at FreeSql.DbContext.<>c__DisplayClass67_0.g__funcUpdate|3(Boolean) + 0x20
at FreeSql.DbContext.FlushCommand() + 0x2ce
at FreeSql.RepositoryDbContext.SaveChanges() + 0x10
at FreeSql.BaseRepository`1.Update(TEntity) + 0x33
at Program.$(String[] args) + 0x16ce
at orm_freesql!+0x833c03
```
### 最小复现项目
[orm_freesql.zip](https://github.com/dotnetcore/FreeSql/files/14863759/orm_freesql.zip)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the attached orm_freesql.zip reproduction and the stack trace entry points in FreeSql.Internal.Utils.GetDataReaderValueBlockExpression, FreeSql.DbContext.FlushCommand, and FreeSql.BaseRepository.Update. Run the .NET 8 NativeAOT example against SQLite and MySQL, then compare the repository update path with the failing expression-generation path. Done means the update completes without the reported InvalidOperationException in the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, mysql, sqlite
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100