File tree Expand file tree Collapse file tree
SharpCoreDB.EntityFrameworkCore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# SharpCoreDB.EntityFrameworkCore - Usage Guide
22
3- ** Version:** ` v1.7.2 `
3+ ** Version:** ` v1.8.0 `
44** Target:** ` .NET 10 ` / ` C# 14 `
55
66This guide focuses on the maintained EF Core provider workflow for SharpCoreDB.
77
88## Install
99
1010``` bash
11- dotnet add package SharpCoreDB.EntityFrameworkCore --version 1.7.2
11+ dotnet add package SharpCoreDB.EntityFrameworkCore --version 1.8.0
1212dotnet add package Microsoft.EntityFrameworkCore.Design
1313```
1414
Original file line number Diff line number Diff line change @@ -489,7 +489,27 @@ private void EnsureCacheLoaded()
489489 return ;
490490 }
491491
492- var rows = JsonSerializer . Deserialize < List < Dictionary < string , object ? > > > ( stream ) ;
492+ // Read the stream into bytes and trim trailing null bytes
493+ using var memoryStream = new MemoryStream ( ) ;
494+ stream . CopyTo ( memoryStream ) ;
495+ var jsonBytes = memoryStream . ToArray ( ) ;
496+
497+ // Trim trailing null bytes
498+ var endIndex = jsonBytes . Length ;
499+ while ( endIndex > 0 && jsonBytes [ endIndex - 1 ] == 0 )
500+ {
501+ endIndex -- ;
502+ }
503+
504+ if ( endIndex == 0 )
505+ {
506+ _rowCache = [ ] ;
507+ _cacheLoaded = true ;
508+ return ;
509+ }
510+
511+ var trimmedJsonBytes = jsonBytes . AsSpan ( 0 , endIndex ) ;
512+ var rows = JsonSerializer . Deserialize < List < Dictionary < string , object ? > > > ( trimmedJsonBytes ) ;
493513 _rowCache = rows ? . Select ( FromSerializableRow ) . ToList ( ) ?? [ ] ;
494514 _cacheLoaded = true ;
495515 }
You can’t perform that action at this time.
0 commit comments