efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Allow to configure a property as non-persisted only for sproc mapping

Open jacontre opened this issue 1 year ago • 1 comments
trafficstars

Is there a way to use InsertUsingStoredProcedure and UpdateUsingStoredProcedure with the same entity and configure it so that I can ignore a property on Update that is not used. Our example is using a CreatedDateTime and LastModifiedTime where both are used in the Insert procedure but then CreatedDateTime is not passed into the update procedure and we would like to ignore it for that case.

jacontre avatar May 03 '24 21:05 jacontre

This depends on https://github.com/dotnet/efcore/issues/14121 Related to https://github.com/dotnet/efcore/issues/28436

AndriySvyryd avatar May 15 '24 20:05 AndriySvyryd

@AndriySvyryd Is there any way to work around this issue, so we could ignore a field, when using InsertUsingStoredProcedure? Maybe it's sufficient in a first step to remove the validation, which requires all fields to be defined as a Parameter, because this clearly doesn't hold for any entity with computed fields.

bytefish avatar Oct 01 '24 12:10 bytefish

@bytefish No, I can't think of a way around this currently, apart from adding a dummy parameter to the sproc.

AndriySvyryd avatar Oct 03 '24 20:10 AndriySvyryd

@AndriySvyryd Thanks for the confirmation and thanks for your work on EF Core! 👍🏻

bytefish avatar Oct 03 '24 20:10 bytefish