Getting a model with nested complex types from Azure Mobile Apps

Hi, I am relatively new to Azure Mobile Apps and Entity Framework, so for some time I struggled with the following.

I have the following model for azure mobile application in .net:

public class Location : EntityData
{ 
     public ProximityRange ProximityRange { get; set; }        
     public double Rssi { get; set; }
     public DateTime TimeOfLocation { get; set; }
}

where ProximityRange is just a container class for two other properties

public class ProximityRange
{
     public double Distance { get; set; }

     public double Accuracy { get; set; }
}

The controller has a way to get all locations on demand.

public IQueryable<Location> GetAllLocations()
{
   var query =  Query();
   return query;

}

But when I call the controller, I only get JSON with TimeOfLocation and Rssi.

In DB table of Location object I have 3 columns

ProximityRange_Accuracy, ProximityRange_Distance and Rssi

I need to get all 3 properties from the GetAllLocations controller as a JSON object.

I tried using $ expand = ProximityRange in the request, but it throws an internal error.

I also tried declaring ProximityRange as ComplexType, but no luck.

It would be very helpful to help someone.

+4
1

( - ) (, DbGeography ProximityRange) Azure Mobile Apps. OData .

- , / JSON. , , - JsonConverter

+2

Source: https://habr.com/ru/post/1650629/


All Articles