Exemple #1
0
        public static async Task <List <T> > FindBy <T>(System.Linq.Expressions.Expression <Func <T, bool> > predicate, FaceRollContext context = null) where T : class
        {
            var result = new List <T>();

            await Task.Run(() =>
            {
                using (context == null ? context = new FaceRollContext() : null)
                {
                    result = context.Set <T>().Where(predicate).ToList();

                    foreach (var item in result)
                    {
                        object entity = item as object;
                    }
                }
            });

            return(result);
        }
Exemple #2
0
        public static async Task <List <T> > GetAll <T>(FaceRollContext context = null) where T : class
        {
            var result = new List <T>();

            await Task.Run(() =>
            {
                using (context == null ? context = new FaceRollContext() : null)
                {
                    result = context.Set <T>().AsQueryable().ToList();

                    foreach (var item in result)
                    {
                        object entity = item as object;
                    }
                }
            });

            return(result);
        }
Exemple #3
0
        public static async Task <T> FindByKey <T>(int key, FaceRollContext context = null) where T : class
        {
            T result = null;

            await Task.Run(() =>
            {
                using (context == null ? context = new FaceRollContext() : null)
                {
                    result = context.Set <T>().Find(key);

                    if (result != null)
                    {
                        object entity = result as object;
                    }
                }
            });

            return(result);
        }