diff options
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.Loading.Sql')
-rw-r--r-- | lib/VNLib.Plugins.Extensions.Loading.Sql/src/DbBuilder.cs | 2 | ||||
-rw-r--r-- | lib/VNLib.Plugins.Extensions.Loading.Sql/src/SqlDbConnectionLoader.cs | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/VNLib.Plugins.Extensions.Loading.Sql/src/DbBuilder.cs b/lib/VNLib.Plugins.Extensions.Loading.Sql/src/DbBuilder.cs index 44d4670..a82fdfa 100644 --- a/lib/VNLib.Plugins.Extensions.Loading.Sql/src/DbBuilder.cs +++ b/lib/VNLib.Plugins.Extensions.Loading.Sql/src/DbBuilder.cs @@ -125,7 +125,7 @@ namespace VNLib.Plugins.Extensions.Loading.Sql if (maxLen.HasValue) { - col.MaxLength = maxLen.Value; + col.MaxLength(maxLen.Value); } //Store the column diff --git a/lib/VNLib.Plugins.Extensions.Loading.Sql/src/SqlDbConnectionLoader.cs b/lib/VNLib.Plugins.Extensions.Loading.Sql/src/SqlDbConnectionLoader.cs index b48ddd1..6f150c8 100644 --- a/lib/VNLib.Plugins.Extensions.Loading.Sql/src/SqlDbConnectionLoader.cs +++ b/lib/VNLib.Plugins.Extensions.Loading.Sql/src/SqlDbConnectionLoader.cs @@ -210,5 +210,40 @@ namespace VNLib.Plugins.Extensions.Loading.Sql //All done! plugin.Log.Debug("Successfully created tables for {type}", typeof(T).Name); } + + /// <summary> + /// A helper method to define a table for a <see cref="IDbContextBuilder"/> + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="builder"></param> + /// <param name="tableName">The optional name of the table to create</param> + /// <param name="callback">The table creation callback function</param> + /// <returns>The original context builder instance</returns> + /// <exception cref="ArgumentNullException"></exception> + public static IDbContextBuilder DefineTable<T>(this IDbContextBuilder builder, string tableName, Action<IDbTableBuilder<T>> callback) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(callback); + + callback(builder.DefineTable<T>(tableName)); + return builder; + } + + /// <summary> + /// A helper method to define a table for a <see cref="IDbContextBuilder"/> + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="builder"></param> + /// <param name="callback">The table creation callback function</param> + /// <returns>The original context builder instance</returns> + /// <exception cref="ArgumentNullException"></exception> + public static IDbContextBuilder DefineTable<T>(this IDbContextBuilder builder, Action<IDbTableBuilder<T>> callback) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(callback); + + callback(builder.DefineTable<T>()); + return builder; + } } } |