AutoDefault userAuthId conversion error

I’m having an issue with the [AutoDefault(Value = “userAuthId”)] when creating/updating with AutoQuery

` [ValidateIsAuthenticated]

[AutoApply(Behavior.AuditCreate)]

[Route("/appointments", "POST")]

public partial class CreateAppointments

        : IReturn<IdResponse>, IPost, ICreateDb<Appointments>

{

    public Guid Id { get; set; }

    public DateTime? ApptDateTime { get; set; }

    public string? Place { get; set; }

    public string? PlaceNotes { get; set; }

    public string? ProviderName { get; set; }

    [AutoDefault(Value = "userAuthId")]

    public int AppUserId { get; set; }

}. `

This is an example DTO and I get the following error:
ServiceStack.OrmLite.IOrmLiteDialectProvider[0]
Error in Int32Converter.ToDbValue() for field ‘AppUserId’ of Type ‘System.Int32’ with value ‘String’
System.FormatException: The input string ‘userAuthId’ was not in a correct format.

I actually had this all working in all my DTO’s autopopulating the AppUserId, and for whatever reason it now throws this error. I tried userAuthId.toInt() from another post on here but still throws the error.

This is the start of my AppUser class:
public partial class AppUser : IUserAuth { [AutoIncrement] public int Id { get; set; }
All auth tables User Id’s are integers, and every reference to the AppUser.Id is integer as well except the session.UserAuthId.

Do you have any ideas what I can be doing wrong? If needed I can make the repo public.

You’re trying to set an integer with a string value, for evaluating #Script expressions use Eval, e.g:

[AutoDefault(Eval = "userAuthId")]

Wow, that did the trick. I wonder how I had it working before? Must have had Eval in there and changed it to Value for some reason. Thanks.

I do have one more question I can’t figure out. I’m guessing I should create another post.

1 Like