Exemplo n.º 1
0
        public override async Task <IEnumerable <Users> > GetAllAsync()
        {
            try
            {
                var result = await _factory.GetConnection()
                             .QueryAsync <Users, Phone, Token, Users>($"" +
                                                                      $"Select * From Users " +
                                                                      $"Inner Join Phone on Users.Id = Phone.UserId " +
                                                                      $"Left Join Token on Users.Id = Token.UserId " +
                                                                      $"", map: (users, phone, token) =>
                {
                    if (phone != null)
                    {
                        users.Phones = new List <Phone>();
                    }
                    users.Phones.Add(phone);

                    if (token != null)
                    {
                        users.Token = token;
                    }

                    return(users);
                });

                return(result.ToList());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public virtual async Task <IEnumerable <T> > GetAllAsync()
        {
            try
            {
                var result = await _factory.GetConnection().QueryAsync <T>($"Select * From { typeof(T).Name }");

                return(result.ToList());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }