Exception when updating DateTime? Field
See original GitHub issueFirst off, awesome library!
I’m trying to set my UpdatedAt
timestamp using the WhenMatched()
call. Here is my code:
_context.Earnings.Upsert(new Earnings
{
EmployeeId = employee.Id,
ContributionGroupId = employee.CurrentEmploymentRecord.ContributionGroupId,
JobPosition = employee.CurrentEmploymentRecord.JobPosition,
PositionStatus = employee.CurrentEmploymentRecord.PositionStatus,
PaymentReason = employee.CurrentEmploymentRecord.PaymentReason,
ImportType = ImportType.MonthEnd,
PostingDate = new DateTime(UploadEarnings.Year, UploadEarnings.Month, 1),
GrossEarnings = earning.Amount.GetValueOrDefault(),
CreatedAt = DateTime.Now,
})
.On(c => new { c.EmployeeId, c.ContributionGroupId, c.JobPosition, c.PositionStatus, c.PaymentReason, c.ImportType, c.PostingDate })
.WhenMatched(c => new Earnings
{
UpdatedAt = DateTime.Now,
GrossEarnings = earning.Amount.GetValueOrDefault()
})
.Run();
I receive the following exception when trying to set the UpdatedAt
value:
The method or operation is not implemented.
If I omit UpdatedAt
or try to set CreatedAt
in WhenMatched()
I do not get the exception. The only difference between the two is that CreatedAt
is a DateTime
type and UpdatedAt
is DateTime?
. Also, If I set UpdatedAt
in the Upsert()
call, I do not get the exception. I’m a newbie, so maybe I’m missing something?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Updating datetime field from a date field throws error in ...
This will supply a varchar value in the format yyyy-MM-ddThh:mm:ss.nnn . For example, with GETDATE() I get the value '2019-11-27T12:32:27.763' ...
Read more >Cannot update nor insert data to datetime field [closed]
So you typed the varchar value 'Receive' in another column of data type int , and it most likely has nothing to do...
Read more >Cannot update DateTime field
Hello,. having trouble setting a datetime typed field. downloadDate__c is a custom field. I'm trying to set the value by assigning to it...
Read more >update datetime field?? - SQL Server Forums
i want to update date field but i am getting error like update emp set convert(varchar(50),date_t,121) = '2006-03-31 19:56:36.933'
Read more >Error while inserting/Updating DateTime field
Hi,. We are trying to update dateTime field using. https://www.methodintegration.com/MethodAPI/service.asmx/MethodAPIUpdateV2.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for the delay in my response… You are correct, it is an issue of of the property being nullable. If I declare a local variable of
DateTime? updatedAt = DateTime.Now;
and then use that value inWhenMatched()
it works. I have also tested version 2.0.2 and the issue is fixed when using the code unmodified from above. Thanks!!!Right, I believe I got this working in the latest version, which is being deployed now: v2.0.2
Please let me know if the parch works, and if we can close this issue 😃