Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite-net guid select returns empty guid

I'm developing a Windows Store App with sqlite as database. I'm using SQLite for Windows Runtime and sqlite-net. Trying to get a list of Guid from a table, but only getting empty guids in the list ({00000000-0000-0000-0000-000000000000}). However when querying only for one guid it works as it should be.

My code is the following:

async void SyncSurveys()
    {
        SQLiteConnection _db = new SQLiteConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "SurveyDB"));

        var localSurveys = (from s in _db.Table<Survey>()
            select s.SurveyGuid).ToList();

        ...
    }

I've tried the query in the following format also, but it is neither works:

var localSurveys = _db.Table<Survey>().Select(s => s.SurveyGuid).ToList();

But if I'm using the following query, to get only one guid just for debug purpose it works well:

var localSurvey = db.Table<Survey>().FirstOrDefault().SurveyGuid;

In the not working scenario the list's count matches the table's rowcount. Does anyone have any idea why this isn't working with the list version?

like image 615
Ferenc Balogh Avatar asked Nov 12 '22 21:11

Ferenc Balogh


1 Answers

This isn't an answer, but it might put you down the right path. I noticed there is an option that can be added to a connection string that sets if GUIDS are stored in binary or not

Data Source=c:\mydb.db;Version=3;BinaryGUID=False;

More info https://www.connectionstrings.com/sqlite/

like image 149
infocyde Avatar answered Nov 14 '22 22:11

infocyde