0

我正在尝试使用 JayStorm 的符合 odata 的云数据库功能进行概念验证。到目前为止一切都很好,但我有一个大问题属于 odata 服务客户端代理序列化类别。

我的odata服务网址是:https ://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/

我创建了一个简单的 .Net 控制台应用程序并向该服务添加服务引用。起初看起来一切都很好,但是 GeoLocation 的服务器端数据类型之间存在不兼容(json有效负载是:{“type”:“Point”,“coordinates”:[-71.56236648559569,42.451074707889646],“crs”:{ "properties":{"name":"EPSG:4326"}) 和添加引用向导选择的客户端类型。似乎它们是非常不同的数据类型,只是客户端选择查询或客户端插入/更新不起作用。例如,下面的代码在 SaveChanges() 行上抛出异常;

System.Data.Services.Client.DataServiceRequestException was unhandled
  HResult=-2146233079
  Message=An error occurred while processing this request.
  Source=Microsoft.Data.Services.Client
  StackTrace:
       at System.Data.Services.Client.SaveResult.HandleResponse()
       at System.Data.Services.Client.BaseSaveResult.EndRequest()
       at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
       at System.Data.Services.Client.DataServiceContext.SaveChanges()
       at JumpSeatDataImporter.Program.Main(String[] args) in c:\Projects\JumpSeat\Dev\JumpSeatWeb\JumpSeatDataImporter\Program.cs:line 24
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Data.Services.Client.DataServiceClientException
       HResult=-2146233079
       Message=Format Exception: Invalid 'Point' format!
    at Function.$data.GeographyBase.validateGeoJSON (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:75:29)
    at GeographyPoint.GeographyBase (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:6:25)
    at new GeographyPoint (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:94:29)
    at $data.oDataConverter.fromDb.$data.GeographyPoint (/usr/lib/node_modules/jaydata/lib/Types/StorageProviders/oData/oDataConverter.js:55:64)
    at Airport.$data.Entity.$data.Class.define.constructor (/usr/lib/node_modules/jaydata/lib/Types/Entity.js:189:41)
    at Airport.Entity (eval at <anonymous> (/usr/lib/node_modules/jaydata/lib/TypeSystem/TypeSystem.js:463:20))
    at new Airport (eval at <anonymous> (/usr/lib/node_modules/jaydata/lib/TypeSystem/TypeSystem.js:463:20))
    at EntitySetProcessor.$data.Class.define.invoke (/usr/lib/node_modules/jaydata/lib/JayService/OData/EntitySetProcessor.js:61:38)
    at JSObjectAdapter.$data.Class.define.processRequest (/usr/lib/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:89:37)
    at JSObjectAdapter.$data.Class.define.handleRequest (/usr/lib/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:165:26)
       StatusCode=500
       InnerException: 

这是代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Spatial;
using System.Text;
using System.Threading.Tasks;

namespace AirportDataImporter
{
    class Program
    {
        static void Main(string[] args)
        {
            var db = new AirprotDB.mydatabaseService(new Uri("https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/"));

            //{"Name":"sfd","Abbrev":"sd","GeoLocation":{"type":"Point","coordinates":[-71.56236648559569,42.451074707889646],"crs":{"properties":{"name":"EPSG:4326"},"type":"name"}}}

            var airport = new JumpSeatDB.Airport();
            airport.Abbrev = "Foo";
            airport.Name = "Bar";

            airport.GeoLocation = GeographyPoint.Create(51.87796, -176.64603);
            db.AddToAirport(airport);

            db.SaveChanges();

            //var foo = db.Airport.ToList();


        }
    }
}

我该怎么做才能让客户端代理使用合适的(自定义声明的?)类,它允许我往返数据,包括 GeoLocation 属性?没有这个,我无法将数据从 sql server 和文件上传/更新到 JayStorm...

您应该能够通过向控制台应用程序添加服务并运行上面提供的代码来完全模拟我的问题。不用担心弄乱数据。

谢谢

4

1 回答 1

0

地理类型目前仅通过 JSON 格式公开(这可能会在中期发生变化),并且 .NET 默认使用 XML,这留下了三个选项:

  • 使用 Data Services Client 5.5.0 和 Data Services Tools 5.3 使您的 .NET 应用程序以 JSON 格式工作(这会生成一个新代理,它接受上下文中的 Format 属性) - 我无法在 .NET 中实现这一点,但我确实希望你比我好:)
  • 您使用 HTML5 页面或 node.js 通过 JayData 库导入您的 POI
  • 您将 csv 文件发布到处理该文件的 JayStorm 服务操作。您使用 HttpRequest 发布到服务操作
于 2013-06-18T08:43:40.450 回答