Skip to content

Conversation

@safigi
Copy link

@safigi safigi commented Dec 6, 2022

finally I figured out how should be implemented

@PawelGerr
Copy link
Owner

Thx, I need some time to analyze the changes.

@safigi
Copy link
Author

safigi commented Dec 11, 2022

Probably we can add excluded property list for defaults or option for skipping PK-s defaults, or both of the tree options.

@PawelGerr
Copy link
Owner

Yes, I would prefer more flexibel approach, similar to KeyProperties or PropertiesToUpdate:

var options = new SqlServerBulkUpdateOptions
{
   KeyProperties = IEntityPropertiesProvider.Include<Customer>(c => c.Id),
   PropertiesToUpdate = IEntityPropertiesProvider.Include<Customer>(c => new { c.FirstName, c.LastName }),

   // new
   SkipIdentityColumnDefinition = IEntityPropertiesProvider.Include<Customer>(c => c.Id),
   SkipDefaultValueDefinition = IEntityPropertiesProvider.Include<Customer>(c => c.Id)
};

await ctx.BulkUpdateAsync(new[] { customer }, options);

A shortcut is possible as well

await ctx.BulkUpdateAsync(new[] { customer },
                          propertiesToUpdate: c => new { c.FirstName, c.LastName },
                          skipIdentityColumnDefinition: c => c.Id,
                          skipDefaultValueDefinition: c => c.Id);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants