Ejemplo n.º 1
0
        public async ValueTask <int> InsertAsync(IRequest <DatabaseIndex> request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var count = 0;

            await foreach (var index in request.GetInputEntitiesAsync().ConfigureAwait(false))
            {
                var tableMapping = TableMapping.GetTableMapping(index.Resource.Type);
                if (index.Resource == null)
                {
                    throw new Exception("Found no resource to register index on");
                }
                var sql = $"CREATE INDEX {index.Name.Fnuttify()} ON {tableMapping.TableName} " +
                          $"({string.Join(", ", index.Columns.Select(c => $"{c.Name.Fnuttify()} {(c.Descending ? "DESC" : "ASC")}"))})";
                await Database.QueryAsync(sql).ConfigureAwait(false);

                count += 1;
            }
            return(count);
        }
Ejemplo n.º 2
0
 public DynamicMemberCollection(TableMapping tableMapping)
 {
     TableMapping    = tableMapping;
     ValueDictionary = new ConcurrentDictionary <string, KeyValuePair <string, object> >(StringComparer.OrdinalIgnoreCase);
 }