question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sequence contains no elements at 5.0.0-alpha

See original GitHub issue

Every operation with collection throw System.InvalidOperationException.

Framework: Xamarin.Forms Platform: Android OS Library Version: 5.0.0-alpha

Code to reproduce:

var db = new LiteDatabase("database.db"));
var collection = db.GetCollection<T>("exampleColleciton");
var allElements= collection.FindAll();

Also Insert, Delete, Find will throw System.InvalidOperationException: Sequence contains no elements StackTrace:


Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source)
LiteDB.Engine.LiteEngine
LiteDB.Engine.LiteEngine..ctor (LiteDB.Engine.EngineSettings settings) [0x0011b] in <c593d84b647a4ed5b475ff841900e3c2>:0
LiteDB
ConnectionString.CreateEngine ()
System
Lazy`1[T].ViaFactory (System.Threading.LazyThreadSafetyMode mode)
System
LazyHelper.ThrowException ()
System
Lazy`1[T].CreateValue ()
System
Lazy`1[T].get_Value ()
System
Lazy`1[T].CreateValue ()
System
Lazy`1[T].get_Value ()
LiteDB
LiteCollection`1[T].Find (LiteDB.Query query, System.Int32 skip, System.Int32 limit)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

3reactions
Envioletcommented, Mar 11, 2020

I ran into the same problem. It only occurs when I create the database completely new (0kB file). The Exception is thrown on LiteDatabase db = new LiteDatabase(liteDbPath). It can however be opened by the LiteDB Studio. I solved the problem by simply downgrading to 4.1.4.

2reactions
bluekuencommented, May 13, 2020

yeah that was the problem, i fixed it by deleting the file creation:

        public string GetDatabasePath()
        {
            var path = Path.Combine(_appData, "ZAsetMobile.db");

            //if (!File.Exists(path))
            //{
            //    using (var streamWriter = new StreamWriter(File.Create(path))) ;
            //}

            return path;
        }

Many thanks for your help! kind regards, bluekuen

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Sequence contains no elements?
When you get the LINQ error "Sequence contains no elements", this is usually because you are using the First() or Single() command rather...
Read more >
Sequence contains no elements, ERROR - Microsoft Q&A
it is an old Entity Framework application that I am trying to reconstruct and get running. Server Error in '/' Application. ... Description:...
Read more >
Error updating trailing stop order ticket (Sequence contains ...
Hi I received this error when updating a StopMarketOrder ticket. The weird issue is the code works fine with just 1 or 2...
Read more >
Navigation | Jetpack
Navigation is a framework for navigating between 'destinations' within an Android application that provides a consistent API whether destinations are ...
Read more >
U.S. Government Research & Development Reports
In mixtures with 5 to 10 % CS2 we have observed first - order anti - Stokes ... This implies that only the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found