Ejemplo n.º 1
0
        static async Task <TResult> PerformDatabaseFunction <TResult>(Func <XamListDatabaseContext, Task <TResult> > databaseFunction) where TResult : class
        {
            using var connection = new XamListDatabaseContext();

            try
            {
                var result = await databaseFunction.Invoke(connection).ConfigureAwait(false);

                await connection.SaveChangesAsync().ConfigureAwait(false);

                return(result);
            }
            catch (Exception e)
            {
                Debug.WriteLine("");
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.ToString());
                Debug.WriteLine("");

                throw;
            }
        }
Ejemplo n.º 2
0
        public static List <ContactModel> GetAllContactModels(Func <ContactModel, bool> wherePredicate)
        {
            using var connection = new XamListDatabaseContext();

            return(connection.Contacts.Where(wherePredicate).ToList());
        }