Beispiel #1
0
        public void Create_WithThisKey_SetsThisKey()
        {
            var thisKey = "friend_id";
            var builder = SqlBatchConfigBuilder.Create(thisKey, "id");

            builder.SqlBatchConfig.ThisKey.Should().Be(thisKey);
        }
Beispiel #2
0
        public void Create_WithParentKey_SetsParentKey()
        {
            var parentKey = "id";
            var builder   = SqlBatchConfigBuilder.Create("friend_id", parentKey);

            builder.SqlBatchConfig.ParentKey.Should().Be(parentKey);
        }
Beispiel #3
0
        public void Create_WhenParentKeyIsNull_ThrowsException()
        {
            Action action = () => SqlBatchConfigBuilder.Create("friend_id", null);

            action.Should()
            .Throw <ArgumentNullException>()
            .Which.ParamName.Should()
            .Be("parentKey");
        }
Beispiel #4
0
        /// <summary>
        /// Configure one to many SQL batching.
        /// </summary>
        /// <param name="fieldConfig">The field config.</param>
        /// <param name="thisKey">The column in this table.</param>
        /// <param name="parentKey">The column in the other table.</param>
        /// <returns>The <see cref="SqlBatchConfigBuilder"/>.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="fieldConfig"/> is <c>null</c>.</exception>
        public static SqlBatchConfigBuilder SqlBatch(this FieldConfig fieldConfig, string thisKey, string parentKey)
        {
            if (fieldConfig == null)
            {
                throw new ArgumentNullException(nameof(fieldConfig));
            }

            var builder = SqlBatchConfigBuilder.Create(thisKey, parentKey);

            fieldConfig.WithMetadata(nameof(SqlBatchConfig), builder.SqlBatchConfig);
            fieldConfig.Resolver ??= DictionaryFieldResolver.Instance;

            return(builder);
        }