The answer of Sami pointed me in the right direction.
.NET outputs a Guid in a different way, so if you store it by using .NET and than use rawsql to fetch the data, then the guid in the rawsql need to be transformed in the same way.
Howerver, in my case it was not the little endian notation.
With the following code you can find the correct string:
var byteArray = new Guid("a8828ddf-ef22-4d36-935a-1c66ae86ebb3").ToByteArray();
string hex = BitConverter.ToString(byteArray).Replace("-", string.Empty);
On my computer, this returns: "DF8D82A822EF364D935A1C66AE86EBB3"
Hence my raw sql will have to be
"select * from [tablename] where ID = X'DF8D82A822EF364D935A1C66AE86EBB3'"
Why I needed this; because I use an in-memory SQLite DB that I populate using EF Core, where I want to test a rawSql command.
This might be handy for others in the same situation. However, keep in mind that a rawSql that works in SQLite might not work on another DB (and vice versa).