You can wrap your call in a try/catch block and in the catch block return an empty row.
I am using Sqlite and Dapper. I need to bypass an exception error and return an empty row when there are no records in the Table or the Database File or Table does not exist.
Ronald Rex
1,666
Reputation points
Hi all Friends,
I am returning rows from a Sqlite/Dapper transaction. And if I run into an exception instead of the application crashing, I would like to return an empty row. Thanks !
Developer technologies .NET .NET MAUI
4,152 questions
Developer technologies C#
11,567 questions
2 answers
Sort by: Most helpful
-
-
Karen Payne MVP 35,586 Reputation points Volunteer Moderator
2023-09-07T15:51:58.9033333+00:00 All these are from me doing simple Google searches
Database exists
if(File.Exists("database.db"))
Table exists
SELECT name FROM sqlite_master WHERE type='table' AND name='{table_name}';
Can not repy to empty row unless I see your C# code.