移动服务+ Xamarin - 同步 - 查询较低的驼峰情况下的参数而不是上部

时间:2016-06-07 16:35:30

标签: xamarin azure-mobile-services

因此,我在c#中创建了一个Azure移动服务项目,并附带了xamarin android mobile应用,它们不希望彼此同步。问题似乎出现在它生成的odata查询上。

我希望这是解决方案

this.mobileService = new MobileServiceClient(Helpers.Keys.AzureServiceUrl)
{
    SerializerSettings = new MobileServiceJsonSerializerSettings()
    {
        CamelCasePropertyNames = true //expected this to solve my problems
    }
};

在同步时,它会创建一个url(注意在updatedAt上的小写驼峰):

http://localhost:64890/tables/CupOfCoffee?$ filter =(updatedAt ge datetimeoffset'1970-01-01T00%3A00%3A00.0000000%2B00%3A00')& $ orderby = updatedAt& $ skip = 0& $顶部= 50&安培; __ includeDeleted =真

服务拒绝

{
  "message": "The query specified in the URI is not valid. Could not find a property named 'updatedAt' on type 'CoffeeAppWebServices.DataObjects.CupOfCoffee'.",
  "exceptionMessage": "Could not find a property named 'updatedAt' on type 'CoffeeAppWebServices.DataObjects.CupOfCoffee'.",
  "exceptionType": "Microsoft.Data.OData.ODataException",
  "stackTrace": "   at Microsoft.Data.OData.Query.EndPathBinder.GeneratePropertyAccessQueryForOpenType(EndPathToken endPathToken, SingleValueNode parentNode)\r\n   at Microsoft.Data.OData.Query.EndPathBinder.BindEndPath(EndPathToken endPathToken, BindingState state)\r\n   at Microsoft.Data.OData.Query.MetadataBinder.BindEndPath(EndPathToken endPathToken)\r\n   at Microsoft.Data.OData.Query.MetadataBinder.Bind(QueryToken token)\r\n   at Microsoft.Data.OData.Query.OrderByBinder.ProcessSingleOrderBy(BindingState state, OrderByClause thenBy, OrderByToken orderByToken)\r\n   at Microsoft.Data.OData.Query.OrderByBinder.BindOrderBy(BindingState state, IEnumerable`1 orderByTokens)\r\n   at Microsoft.Data.OData.Query.ODataUriParser.ParseOrderByImplementation(String orderBy, IEdmType elementType, IEdmEntitySet entitySet)\r\n   at Microsoft.Data.OData.Query.ODataUriParser.ParseOrderBy(String orderBy, IEdmType elementType, IEdmEntitySet entitySet)\r\n   at Microsoft.Data.OData.Query.ODataUriParser.ParseOrderBy(String orderBy, IEdmModel model, IEdmType elementType)\r\n   at System.Web.Http.OData.Query.OrderByQueryOption.get_OrderByClause()\r\n   at System.Web.Http.OData.Query.Validators.OrderByQueryValidator.Validate(OrderByQueryOption orderByOption, ODataValidationSettings validationSettings)\r\n   at System.Web.Http.OData.Query.OrderByQueryOption.Validate(ODataValidationSettings validationSettings)\r\n   at System.Web.Http.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\r\n   at System.Web.Http.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings)\r\n   at System.Web.Http.OData.EnableQueryAttribute.ValidateQuery(HttpRequestMessage request, ODataQueryOptions queryOptions)\r\n   at System.Web.Http.OData.EnableQueryAttribute.ExecuteQuery(Object response, HttpRequestMessage request, HttpActionDescriptor actionDescriptor)\r\n   at System.Web.Http.OData.EnableQueryAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)"
}

失败了...... 相当简单地将查询参数从'updatedAt'更改为'UpdatedAt'(上部驼峰案例或pascal案例),它将使上述查询起作用。如何让xamarin应用程序以这种方式生成或让移动服务接受较低的驼峰案例变体,这对webapi更加有用,只是接受这两种格式?

作为相关说明:移动服务上的咖啡杯实体实现 EntityData

但我似乎无法在教程中找到任何提及将低骆驼箱转换为鞋面的内容。

有什么想法吗?或者需要更多信息......?

提前致谢。

1 个答案:

答案 0 :(得分:2)

您正在将Azure移动应用与Azure移动服务进行混合和匹配。它们不兼容。

此时您最好的想法是将移动服务切换到App Service。您可以在此处找到有关升级的信息:https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-net-upgrading-from-mobile-services/