Thinktecture.EntityFrameworkCore icon indicating copy to clipboard operation
Thinktecture.EntityFrameworkCore copied to clipboard

temptable without defaults

Open safigi opened this issue 3 years ago • 3 comments

finally I figured out how should be implemented

safigi avatar Dec 06 '22 12:12 safigi

Thx, I need some time to analyze the changes.

PawelGerr avatar Dec 09 '22 17:12 PawelGerr

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

safigi avatar Dec 11 '22 10:12 safigi

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);

PawelGerr avatar Dec 12 '22 16:12 PawelGerr