Esempio n. 1
0
        public override async Task <IKeyQueryableMap <Guid, Item> > CreateAsync(params KeyValuePair <Guid, Item>[] values)
        {
            var columns = typeof(Item)
                          .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                          .ToSqlColumns();

            columns.Add("Key", new SqlType(DbType.Guid));
            var table = new Table("GuidItems", new[] { "Key" }, columns);

            _serverFixture.DropTable(table.Schema, table.Name);

            var keyMapper   = new ValueMapper <Guid>("Key");
            var valueMapper = new TypeMapper <Item>(table);
            var map         = new SqlMap <Guid, Item>(_serverFixture.DatabaseDriver, _serverFixture.ConnectionString, table, keyMapper, valueMapper);

            foreach (var value in values)
            {
                await map.TryAddAsync(value.Key, value.Value);
            }

            return(map);
        }