[BUG] Collection returns incorrect count when database loaded from memory stream
See original GitHub issueVersion LiteDB commit 6d9ac6237ff8cae104a3c57a8de4ec55b4506e87 (June 15, 2022)
Describe the bug Collection returns incorrect count when database loaded from memory stream
Code to Reproduce
using LiteDB;
using System.Diagnostics;
using System.Text;
public static class Program
{
public static void Main(string[] args)
{
const string DbName = "v5-test.db";
var dbStr = File.ReadAllText(DbName);
var strm = new MemoryStream(Encoding.ASCII.GetBytes(dbStr));
using var db = new LiteDatabase(strm);
// This works as expected
//using var db = new LiteDatabase(DbName);
var col1 = db.GetCollection("col1");
var count = col1.Count();
Debug.Assert(count == 3);
}
}
Expected behavior Collection count should be 3 but is 0
Additional context see also #2247
Issue Analytics
- State:
- Created 10 months ago
- Comments:6
Top Results From Across the Web
Is a memory leak created if a MemoryStream in .NET is not ...
In this case, the function is returning a MemoryStream because it provides "data that can be interpreted differently depending on calling ...
Read more >Collector Troubleshooting and FAQ
This section provides frequently asked questions about collecting data into Sumo Logic and the answers you need.
Read more >Troubleshooting migration tasks in AWS Database Migration ...
The most common reason for a migration task running slowly is that there are inadequate resources allocated to the AWS DMS replication instance....
Read more >MemoryStream Class (System.IO)
Initializes a new non-resizable instance of the MemoryStream class based on the specified byte array with the CanWrite property set as specified.
Read more >Windows Sockets Error Codes (Winsock2.h) - Win32 apps
The Windows function is indicating a lack of required memory resources. WSA_INVALID_PARAMETER; 87. One or more parameters are invalid.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the guidance. It is now working as expected!