Closed ghost closed 4 years ago
Hi @testbench, if your collection doesnt contains an index in CaseGUID column, LiteDB try to auto-create this index and if you are readonly mode you get this error.
Try open shared/exclusive mode and create this index.
In next v3.5 version there is no more auto index and in this case, LiteDB will do a full scan search.
Hi,
thanks for the quick response. I have two issues with this, being:
1 - When set to exclusive mode I get errors with the file being locked by another process 2 - When attempting to set Mode=Shared I get the error "'Invalid connection string value type for [mode]'"
My packages.config contains: package id="LiteDB" version="3.1.2" targetFramework="net452"
Hi,
1- Exclusive mode can be open only one-per-time. Dont forget to always use using
statement to compiler call Dispose() method
2- There is no shared option in NetStandard version. You must use net35 version to enable this option.
Whats the process for using the net35 version?
do you simply mean having my project target .Net 3.5?
I was reviewing nuget and net451
are the same net35
. Downgrade you problem to net451 and get from nuget
Removed LiteDB, downgraded to 4.5.1 and used nuget to install litedb 3.1.2, same error "'Invalid connection string value type for [mode]'"
Any ideas?
Hi @mbdavid
Retargetting to 4.5.1 and reinstalling litedb did not make any difference. Same error. Any other suggestions?
Thanks
Ok, now comparing new .csproj in master branch with dev branch they are different. You must set your project to .NET3.5 to download correct version. I'm fixing this for new 3.5 version
OK will try this thanks
@mbdavid I have it running fine with v3.1.1 - when do you expect the new v3.5 to be available?
HI @testbench, I will delivery beta version next week. An them, I will wait community helps me testing and finding bugs (especially about concurrency access).
Thanks @mbdavid - well done on the project too, it's great!
I'm new in LiteDB. So guys, what is the solution? I have db as embedded resource and here is the usage:
public static void AddUser(long id, string name)
{
using (var memory = typeof(DbActions).GetTypeInfo().Assembly.GetManifestResourceStream("HadithBot.UmmahDb.db"))
{
using (var db = new LiteDatabase(memory))
{
var table = db.GetCollection<User>("Users");
if (!table.Exists(u => u.ChatId == id))
{
var user = new User()
{
Name = name,
ChatId = id,
IsAdmin = false
};
table.Insert(user);
table.EnsureIndex("ChatId", true);
}
}
}
}
There I get this error. What is wrong? I'm work with netcore.
Hi @a-a-k, it's not possible modify embedded assembly resource. Use an external file or in-memory stream
@mbdavid thanks for your response. Could you provide any example of usage "in-memory stream"?
You can use MemoryStrem
class as your database stream.
var mem = new MemoryStrem();
using(var db = new LiteDatabase(mem))
{
// ...
}
var databaseInBytes = mem.ToArray();
@mbdavid I've saw that at Quickstart page but this usage unclear for me. What is the profit of such way? Will it only runtime data? Please, explain this way or give me link to explanation )
Memory databases are useful for unit test or some in-memory processing, like create a temporary database for sort data using an index. In this thread https://github.com/mbdavid/LiteDB/issues/805 I made some examples
Hi! With the objective of organizing our issues, we are closing old unsolved issues. Please check the latest version of LiteDB and open a new issue if your problem/question/suggestion still applies. Thanks!
Hi,
Using the following code causes a "Stream does not support writing" exception:
public IEnumerable getCaseByCaseGUID(Guid CaseGUID)
{
using (var db = new LiteDatabase(NoSQLDatabaseReadOnly))
{
var Case = db.GetCollection(NoSQLCollectionName);
My connection string (NoSQLDatabaseReadOnly) has Mode=ReadOnly in it.
Trying to figure out why a Find call is attempting to write to the database? Is this by design? What are the workarounds?
Thanks.