Open Closed

Xamarin : NullableIdDto not parsed on flurl query params #6265


0
ricavir created

Hi,

I'm developing a mobile app with zero xamarin template. I'm trying to get data from an appservice that works well... but on mobile app NullableIdDto<long> is mmissing from query parameter.

Here is the method that I'm calling :

Task&lt;NoteEditOutput&gt; GetNoteEdit(GetNoteInput input);

GetNoteInput :

public class GetNoteInput
    {
        public NullableIdDto&lt;long&gt; NullableId { get; set; }   
        public long? AddressId { get; set; }
        public long? OwnerId { get; set; }
        public long? OpportunityId { get; set; }
        public long? ContactId { get; set; }
        public long? SupplierId { get; set; } 
    }

Xamarin code is :

var input = new GetNoteInput();
    input.NullableId = new NullableIdDto&lt;long&gt;(note?.Id);    // Id = 91
    var noteFromServer = await _noteAppService.GetNoteEdit(input);
    Model = ObjectMapper.Map&lt;NoteEditOutputModel&gt;(noteFromServer);

This request results on following JSON object :

{ "input": { "nullableId": null, "addressId": null, "ownerId": null, "opportunityId": null, "contactId": null, "supplierId": null } }

Should be :

{ "input": { "nullableId": { "id": 91 }, "addressId": null, "ownerId": null, "opportunityId": null, "contactId": null, "supplierId": null } }

Is this linked with a Flurl configuration ? How can I fix that ?


5 Answer(s)
  • 0
    alper created
    Support Team

    There's a similar usage in UserDetailsViewModel.cs in InitializeAsync() method. GetUserForEdit also uses NullableIdDto without any issues.

     var user = await _userAppService.GetUserForEdit(new NullableIdDto&lt;long&gt;(userListModel?.Id));
    

    See this code as an example https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Mobile.Shared/ViewModels/UserDetailsViewModel.cs#L182

  • 0
    ricavir created

    Hi Alper,

    We are not talking about the same thing. I have a lot of viewmodels based on UserDetailsViewModel.cs that are using NullableIdDto<long> as a the base class for method argument. This case works like a charm, no problem here.

    My issue is when I'm passing an other object as base class that is using NullableIdDto<long> as property like this :

    public class GetNoteInput
        {
            **public NullableIdDto&lt;long&gt; NullableId { get; set; } **  
            public long? AddressId { get; set; }
            public long? OwnerId { get; set; }
            public long? OpportunityId { get; set; }
            public long? ContactId { get; set; }
            public long? SupplierId { get; set; } 
        }
    

    I've been testing several use cases : as you know, Xamarin development can take a lot of time with these small issues.

    I have more than 50 xamarin views on the project that are getting data from server without any issue... but when nullableiddto is not the base class, nullableiddto value is always passing null value to the server.

    Sorry for the first message, it was maybe not clear enougth to make you understand.

  • 0
    alper created
    Support Team

    I got it. Needs to be reproduced. You can create an issue about it.

  • 0
    ricavir created

    https://github.com/aspnetzero/aspnet-zero-core/issues/2079

  • 0
    alper created
    Support Team

    being tracked from the GitHub issue.