Closed cap1024 closed 7 months ago
Please add support DateTime values. Following example produces NullReferenceException:
Action<EntityTypeBuilder<SourceEntity>> builder = x => x.AfterUpdate(trigger => trigger .Action(action => action .Update<DestinationEntity>( (tableRefs, destinationEntities) => destinationEntities.StringField == tableRefs.New.StringField + tableRefs.Old.StringField, (tableRefs, destinationEntities) => new DestinationEntity { DateTimeValue = DateTime.UtcNow })));
Useful case:
MofiedOn = DateTime.UtcNow
Just to save time to search for a place with an error:
public sealed class MemberExpressionVisitor : BaseExpressionVisitor<MemberExpression> { private string GetTableSql(MemberExpression memberExpression, ArgumentType argumentType) { if (memberExpression.Member.TryGetNewTableRef(out _)) { return _generator.NewEntityPrefix; } if (memberExpression.Member.TryGetOldTableRef(out _)) { return _generator.OldEntityPrefix; } return memberExpression.Expression != null ? GetColumnSql(memberExpression.Expression.Type, memberExpression.Member, argumentType) : GetMethodSql(memberExpression); } private string GetMethodSql(MemberExpression memberExpression) { var method = memberExpression.ToString(); switch (method) { case "String.Empty": return _generator.GetSql(string.Empty); case "DateTime.UtcNow": return "GetUtcDate()"; // for SQL Server } throw new InvalidOperationException($"Unknown method: {method}"); } }
Hello. I added support for DateTime.UtcNow in the latest version.
Hello! Thank a lot! I've added PR with minor changes. Pls, review it.
Please add support DateTime values. Following example produces NullReferenceException:
Useful case:
Just to save time to search for a place with an error: