Skip to content

Commit 290074d

Browse files
committed
update documentation
1 parent dbd2a0f commit 290074d

25 files changed

+793
-851
lines changed

src/FluentCommand.SqlServer/Bulk/DataBulkCopy.cs

Lines changed: 40 additions & 150 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
using Microsoft.Data.SqlClient;
1+
using Microsoft.Data.SqlClient;
22

33
namespace FluentCommand.Bulk;
44

55
/// <summary>
6-
/// Bulk Copy extension methods
6+
/// Provides extension methods for starting and configuring SQL Server bulk copy operations.
77
/// </summary>
88
public static class DataBulkCopyExtensions
99
{
1010
/// <summary>
11-
/// Starts a data bulk-copy with the specified destination table name.
11+
/// Starts a bulk copy operation using the specified data session and destination table name.
1212
/// </summary>
13-
/// <param name="session">The session to use for the bulk-copy.</param>
14-
/// <param name="destinationTable">Name of the destination table on the server.</param>
13+
/// <param name="session">The <see cref="IDataSession"/> to use for the bulk copy operation.</param>
14+
/// <param name="destinationTable">The name of the destination table on the SQL Server.</param>
1515
/// <returns>
16-
/// A fluent <see langword="interface" /> to a <see cref="SqlBulkCopy " /> operation.
16+
/// An <see cref="IDataBulkCopy"/> instance for configuring and executing the bulk copy operation.
1717
/// </returns>
1818
public static IDataBulkCopy BulkCopy(this IDataSession session, string destinationTable)
1919
{
2020
var bulkCopy = new DataBulkCopy(session, destinationTable);
2121
return bulkCopy;
2222
}
23-
2423
}

src/FluentCommand.SqlServer/Bulk/DataBulkCopyMapping.cs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
using System.Linq.Expressions;
22
using System.Reflection;
33

4-
using Microsoft.Data.SqlClient;
5-
64
namespace FluentCommand.Bulk;
75

86
/// <summary>
9-
/// A builder class for <see cref="IDataBulkCopy"/> column mapping.
7+
/// Provides a builder for configuring column mappings for <see cref="IDataBulkCopy"/> operations using strongly typed lambda expressions.
108
/// </summary>
11-
/// <typeparam name="TEntity">The type of the entity.</typeparam>
9+
/// <typeparam name="TEntity">The type of the entity being mapped.</typeparam>
1210
public class DataBulkCopyMapping<TEntity>
1311
{
1412
private readonly IDataBulkCopy _bulkCopy;
1513

1614
/// <summary>
1715
/// Initializes a new instance of the <see cref="DataBulkCopyMapping{TEntity}"/> class.
1816
/// </summary>
19-
/// <param name="bulkCopy">The bulk copy.</param>
17+
/// <param name="bulkCopy">The <see cref="IDataBulkCopy"/> instance to configure column mappings for.</param>
2018
internal DataBulkCopyMapping(IDataBulkCopy bulkCopy)
2119
{
2220
_bulkCopy = bulkCopy;
2321
}
2422

2523
/// <summary>
26-
/// Creates a new column mapping using a Lamba express to refer to source and destination columns.
24+
/// Creates a new column mapping using a lambda expression to refer to both the source and destination columns by property name.
2725
/// </summary>
28-
/// <typeparam name="TValue">The type of the value.</typeparam>
29-
/// <param name="sourceProperty">A Lambda expression representing the property of the source column for the mapping.</param>
26+
/// <typeparam name="TValue">The type of the property value.</typeparam>
27+
/// <param name="sourceProperty">A lambda expression representing the property of the source column for the mapping.</param>
3028
/// <returns>
31-
/// A fluent <see langword="interface" /> to a <see cref="SqlBulkCopy " /> operation.
29+
/// The same <see cref="DataBulkCopyMapping{TEntity}"/> instance for fluent chaining.
3230
/// </returns>
3331
public DataBulkCopyMapping<TEntity> Mapping<TValue>(Expression<Func<TEntity, TValue>> sourceProperty)
3432
{
@@ -39,13 +37,13 @@ public DataBulkCopyMapping<TEntity> Mapping<TValue>(Expression<Func<TEntity, TVa
3937
}
4038

4139
/// <summary>
42-
/// Creates a new column mapping, using a Lamba express to refer to source column and a column name for the target column.
40+
/// Creates a new column mapping using a lambda expression to refer to the source column and a column name for the destination column.
4341
/// </summary>
44-
/// <typeparam name="TValue">The type of the value.</typeparam>
45-
/// <param name="sourceProperty">A Lambda expression representing the property of the source column for the mapping.</param>
42+
/// <typeparam name="TValue">The type of the property value.</typeparam>
43+
/// <param name="sourceProperty">A lambda expression representing the property of the source column for the mapping.</param>
4644
/// <param name="destinationColumn">The name of the destination column within the destination table.</param>
4745
/// <returns>
48-
/// A fluent <see langword="interface" /> to a <see cref="SqlBulkCopy " /> operation.
46+
/// The same <see cref="DataBulkCopyMapping{TEntity}"/> instance for fluent chaining.
4947
/// </returns>
5048
public DataBulkCopyMapping<TEntity> Mapping<TValue>(Expression<Func<TEntity, TValue>> sourceProperty, string destinationColumn)
5149
{
@@ -56,13 +54,13 @@ public DataBulkCopyMapping<TEntity> Mapping<TValue>(Expression<Func<TEntity, TVa
5654
}
5755

5856
/// <summary>
59-
/// Creates a new column mapping, using a Lamba express to refer to source column and a column ordinal for the target column.
57+
/// Creates a new column mapping using a lambda expression to refer to the source column and a column ordinal for the destination column.
6058
/// </summary>
61-
/// <typeparam name="TValue">The type of the value.</typeparam>
62-
/// <param name="sourceProperty">A Lambda expression representing the property of the source column for the mapping.</param>
59+
/// <typeparam name="TValue">The type of the property value.</typeparam>
60+
/// <param name="sourceProperty">A lambda expression representing the property of the source column for the mapping.</param>
6361
/// <param name="destinationOrdinal">The ordinal position of the destination column within the destination table.</param>
6462
/// <returns>
65-
/// A fluent <see langword="interface" /> to a <see cref="SqlBulkCopy " /> operation.
63+
/// The same <see cref="DataBulkCopyMapping{TEntity}"/> instance for fluent chaining.
6664
/// </returns>
6765
public DataBulkCopyMapping<TEntity> Mapping<TValue>(Expression<Func<TEntity, TValue>> sourceProperty, int destinationOrdinal)
6866
{
@@ -73,12 +71,12 @@ public DataBulkCopyMapping<TEntity> Mapping<TValue>(Expression<Func<TEntity, TVa
7371
}
7472

7573
/// <summary>
76-
/// Ignores the specified source column by removing it from the mapped columns collection.
74+
/// Ignores the specified source column by removing it from the mapped columns collection, using a lambda expression to specify the property.
7775
/// </summary>
78-
/// <typeparam name="TValue">The type of the value.</typeparam>
79-
/// <param name="sourceProperty">A Lambda expression representing the property of the source column for the mapping.</param>
76+
/// <typeparam name="TValue">The type of the property value.</typeparam>
77+
/// <param name="sourceProperty">A lambda expression representing the property of the source column to ignore.</param>
8078
/// <returns>
81-
/// A fluent <see langword="interface" /> to a <see cref="SqlBulkCopy " /> operation.
79+
/// The same <see cref="DataBulkCopyMapping{TEntity}"/> instance for fluent chaining.
8280
/// </returns>
8381
public DataBulkCopyMapping<TEntity> Ignore<TValue>(Expression<Func<TEntity, TValue>> sourceProperty)
8482
{
@@ -88,7 +86,15 @@ public DataBulkCopyMapping<TEntity> Ignore<TValue>(Expression<Func<TEntity, TVal
8886
return this;
8987
}
9088

91-
89+
/// <summary>
90+
/// Extracts the column name from the provided lambda expression, using property attributes if available.
91+
/// </summary>
92+
/// <typeparam name="TValue">The type of the property value.</typeparam>
93+
/// <param name="sourceProperty">A lambda expression representing the property.</param>
94+
/// <returns>The resolved column name for the property.</returns>
95+
/// <exception cref="ArgumentException">
96+
/// Thrown if the expression does not represent a property access.
97+
/// </exception>
9298
private string ExtractColumnName<TValue>(Expression<Func<TEntity, TValue>> sourceProperty)
9399
{
94100
var memberExpression = sourceProperty.Body as MemberExpression;

0 commit comments

Comments
 (0)