Interacting with Azure and Xamarin

Eduardo Gomez 3,426 Reputation points
2021-10-11T00:02:45.043+00:00

Hello

I am redesigning my notes app and changing firebase with azure.

I am trying to insert a user into my Database, I already went to the portal, and using Azure Data Studio, I created all my tables (I do not know if you have t do anything else, like setting permission)

My VM is supposed to register my Usrer

 [AddINotifyPropertyChangedInterface]  
    public class LoginPageViewModel {  
  
        public ICommand OpenRegisterPopupCommand { get; set; }  
  
        public ICommand Register { get; set; }  
  
        public ICommand Login { get; set; }  
  
        public Users Users { get; set; }  
  
        public bool IsRegisterAllowed { get; set; }  
  
        public bool IsPopUpOpen { get; set; }  
  
  
  
        public LoginPageViewModel() {  
  
            Users = new Users {  
                OnAnyPropertiesChanged = () => {  
  
                    (Login as Command).ChangeCanExecute();  
                    (Register as Command).ChangeCanExecute();  
  
                }  
            };  
  
            Login = new Command(LoginAction, CanPreformAction);  
  
            Register = new Command(RegisterAction, CanPreformAction);  
  
            OpenRegisterPopupCommand = new Command(() => {  
                IsPopUpOpen = true;  
            });  
        }  
  
        private bool CanPreformAction(object arg) {  
  
            return Users != null && !string.IsNullOrEmpty(Users.Email) && !string.IsNullOrEmpty(Users.Password);  
  
        }  
  
        private async void RegisterAction(object obj) {  
  
            await App.client.GetTable<Users>().InsertAsync(Users);  
  
        }  

  
        public string Id { get; set; }  
  
        [OnChangedMethod(nameof(OnPropertyChanged))]  
        public string Email { get; set; }  
  
        [OnChangedMethod(nameof(OnPropertyChanged))]  
        public string Password { get; set; }  
  
        public Action OnAnyPropertiesChanged { get; set; }  
        private void OnPropertyChanged() {  
            OnAnyPropertiesChanged?.Invoke();  
        }  

But when I try to register, get this error

Newtonsoft.Json.JsonSerializationException: 'Self referencing loop detected for property 'Users' with type 'DuoNotes.Model.Users'. Path 'OnAnyPropertiesChanged.Target'.'

    public string Id { get; set; }  

    [OnChangedMethod(nameof(OnPropertyChanged))]  
    public string Email { get; set; }  

    [OnChangedMethod(nameof(OnPropertyChanged))]  
    public string Password { get; set; }  

    public Action OnAnyPropertiesChanged { get; set; }  
    private void OnPropertyChanged() {  
        OnAnyPropertiesChanged?.Invoke();  
    }  


        

139247-screenshot-2021-10-11-020145.png

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
Azure SQL Database
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,951 Reputation points
    2021-10-11T08:14:34.587+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Newtonsoft.Json.JsonSerializationException: 'Self referencing loop detected for property 'Users' with type 'DuoNotes.Model.Users'. Path 'OnAnyPropertiesChanged.Target'.'

    This exception is caused by the loop reference error with serialization. To fix this, please set ReferenceLoopHandling to ReferenceLoopHandling.Ignore.

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful