Exemple #1
0
 public async Task <IEnumerable <TenantDto> > LoadAllTenantsAsync()
 {
     return(await _db.Query <Dal.Models.Tenant>().Select(x => new TenantDto
     {
         Id = x.Id,
         Name = x.Name
     }).ToListAsync());
 }
Exemple #2
0
        public virtual async Task <IEnumerable <TEntity> > ExecuteQueryAsync <TEntity>(string procNameWithParamNames, KeyValuePair <string, object>[] inData, bool isEntitySet = false) where TEntity : class
        {
            try
            {
                using (var context = new TodoDbContext())
                {
                    var parameterString = string.Join(",", inData.Select(k => !(k.Value.GetType() != typeof(string)) ? $"'{k.Value}'" : k.Value).ToArray());
                    var query           = $"call {procNameWithParamNames} ({parameterString})";
                    IEnumerable <TEntity> queryResult = isEntitySet ?
                                                        await context.Set <TEntity>().FromSql(query).ToListAsync() :
                                                        await context.Query <TEntity>().FromSql(query).ToListAsync();

                    return(queryResult);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }