We are developing Data access framework library to be called by Business components to access SQLlite DB for Xamarin app. To execute SELECT Sql against DB, following method have been written. Am new to anonymous methods and using new features, so need suggestions Am looking for anyways to improve efficiency in this implementation.
private static readonly Lazy<AppDB> Lazy = new Lazy<AppDB>(() => new AppDB());
public static AppDB Instance => Lazy.Value;
private SQLiteAsyncConnection _conn =null;
static object locker = new object();
private SQLiteAsyncConnection DbConnection
{
get
{
if (_conn == null)
{
LazyInitializer.EnsureInitialized(ref _conn, DependencyService.Get<ISQLite>().GetAsyncConnection);
}
return _conn;
}
}
public List<T> ExecuteQuery<T>(string sqlQuery, object[] parameters = null) where T: class
{
List<T> l = new List<T>();
try
{
l = parameters !=null ? DbConnection.QueryAsync<T>(sqlQuery,parameters).Result : DbConnection.QueryAsync<T>(sqlQuery).Result;
}
catch (Exception e)
{ }
return l;
}