You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an object which contains the properties CreatedAt and UpdatedAt. I would like to exclude the UpdatedAt property on insert and the CreatedAt property at update. As I don't know if the object already exists, both properties are set with a datetime. On executing the BulkInsertOrUpdateOrDelete method I'm getting an Microsoft.Data.SqlClient.SqlException with the message Invalid column name "UpdatedAt".
MERGE [dbo].[Item] WITH (HOLDLOCK) AS T USING
(
SELECT TOP 1*FROM [dbo].[ItemTempf9f7258f]
ORDER BY [Id]
)
AS S ON T.[Id] = S.[Id] WHEN NOT MATCHED BY TARGET THEN
INSERT ([CreatedAt], [Deleted], [Text])
VALUES (S.[CreatedAt], S.[Deleted], S.[Text])
WHEN MATCHED AND EXISTS
(
SELECT S.[CreatedAt], S.[Deleted], S.[Text]
EXCEPT
SELECT T.[CreatedAt], T.[Deleted], T.[Text]
)
THEN
UPDATESET T.[UpdatedAt] = S.[UpdatedAt];
WHEN NOT MATCHED BY SOURCE THEN DELETE;
What am I doing wrong?
Any help is much appreciated!
The text was updated successfully, but these errors were encountered:
MERGE [dbo].[Item] WITH (HOLDLOCK) AS T USING
(
SELECT TOP 1*FROM [dbo].[ItemTempc6b85062]
ORDER BY [Id]
)
AS S ON T.[Id] = S.[Id] WHEN NOT MATCHED BY TARGET THEN
INSERT ([Text], [CreatedAt], [Deleted])
VALUES (S.[Text], S.[CreatedAt], S.[Deleted])
WHEN MATCHED AND EXISTS
(
SELECT S.[Text], S.[CreatedAt], S.[Deleted]
EXCEPT
SELECT T.[Text], T.[CreatedAt], T.[Deleted]
)
THEN
UPDATESET
T.[Text] = S.[Text],
T.[UpdatedAt] = S.[UpdatedAt],
T.[Deleted] = S.[Deleted];
WHEN NOT MATCHED BY SOURCE THEN DELETE;
But I'm still getting the Microsoft.Data.SqlClient.SqlException with the message Invalid column name "UpdatedAt".
I am pretty sure I have the exact same scenario/requirement. I have a Created and Updated column but I want to exclude the Updated from the original INSERT.
It feels like we need the equivalent of PropertiesToExcludeOnUpdate for the Insert. Something like PropertiesToExcludeOnInsert?
I have an object which contains the properties
CreatedAt
andUpdatedAt
. I would like to exclude theUpdatedAt
property on insert and theCreatedAt
property at update. As I don't know if the object already exists, both properties are set with a datetime. On executing theBulkInsertOrUpdateOrDelete
method I'm getting anMicrosoft.Data.SqlClient.SqlException
with the messageInvalid column name "UpdatedAt"
.This is my configuration:
This is the generated sql statement:
What am I doing wrong?
Any help is much appreciated!
The text was updated successfully, but these errors were encountered: