@@ -413,7 +413,7 @@ private string ToSqlExpression<TEntity>(DbContext context, TableMetadata table,
413413
414414 /// <summary>
415415 /// Extracts update SQL statements from a MemberInitExpression, handling both simple properties
416- /// and nested complex property initializations.
416+ /// and nested complex property initializations recursively .
417417 /// </summary>
418418 /// <param name="context">DB context</param>
419419 /// <param name="table">Table metadata</param>
@@ -428,16 +428,15 @@ private IEnumerable<string> GetUpdatesFromMemberInit<T>(DbContext context, Table
428428 // Check if the binding expression is a nested MemberInitExpression (complex property assignment)
429429 if ( binding . Expression is MemberInitExpression nestedMemberInit )
430430 {
431- // Recursively process nested complex property assignments
432- foreach ( var nestedBinding in nestedMemberInit . Bindings . OfType < MemberAssignment > ( ) )
431+ // Recursively process nested complex property assignments to handle arbitrary nesting levels
432+ foreach ( var update in GetUpdatesFromMemberInit < T > ( context , table , nestedMemberInit , lambda ) )
433433 {
434- // For complex properties, the column name is the nested property name (e.g., "Code", "Name")
435- yield return $ "{ table . GetQuotedColumnName ( nestedBinding . Member . Name ) } = { ToSqlExpression < T > ( context , table , nestedBinding . Expression , lambda ) } ";
434+ yield return update ;
436435 }
437436 }
438437 else
439438 {
440- // Simple property assignment
439+ // Simple property assignment - the column name is the property name
441440 yield return $ "{ table . GetQuotedColumnName ( binding . Member . Name ) } = { ToSqlExpression < T > ( context , table , binding . Expression , lambda ) } ";
442441 }
443442 }
0 commit comments