11using System . Linq . Expressions ;
22using System . Reflection ;
33
4- using Microsoft . Data . SqlClient ;
5-
64namespace 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>
1210public 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