locked
NetFX 4.0, SyncFX 2.1, SQLCE and the Geography Datatype RRS feed

  • Question

  • Introduction:

    We're building a large-scale medical system with hundrends of clients. Since the clients are only occasionally connected, we found SyncFX to be a native choice for this project.

    The clients run on a tiny MID (Intel ATOM-based hardware powered by Windows 7) with our custom WPF application, hosting SQLCE 3.5 SP2 as a local data store. The servers run SQL Server 2008 R2, which stores logging information from all clients.

    So far we've made some tests with 3-4 clients and a single server, and SyncFX seems to work as expected.

    The Problem:

    We want the clients to log location (GPS) data, and make calculations based on locations on the servers - for which the "Geography" datatype seems to be a perfect choice.

    However, SQLCE does not support the Geography datatype. I've read in an official MS document (http://msdn.microsoft.com/en-us/library/ms171931.aspx) that when syncing/replicating SQL 2008 R2 to SQLCE (3.5 sp1 and above), the "Geography" datatype on the server becomes an "image" datatype on the client. In our scenario, the clients themselves collect the location data, but do not use it. Only the servers should use it later for location-based calculation.

    Is there a way to parse the data from the converted "image" into some meaningful location information using .NET code?

    Or, more important, is there a way to encode location data, from a .NET application, into a "binary" field that can then be synced back to the servers?

    Can someone provide a .NET code example for such conversion?


    Thanks in advance!

    Thursday, May 5, 2011 10:18 AM

Answers

All replies

  • Hi,

    SyncFx database provider is built on top of ADO.Net. I don't think Geography type is supported by ADO.net yet. When you wrote your prototype, did you try with Geography SQL type yet?

    If you are using SqlSyncProvider and SqlCeSyncProvider for your scenario, you could consider creating DbSyncScopeDescription with Nvarchar for the Geography column, it will be understood by client side. You can reference this forum post for how to coding it: http://social.msdn.microsoft.com/Forums/en-US/syncdevdiscussions/thread/8f29a2f0-03c9-4609-b04b-574acf71f5a8

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Thursday, May 5, 2011 11:58 PM
  • SyncFx database provider is built on top of ADO.Net. I don't think Geography type is supported by ADO.net yet.

    I found the following example: http://consultingblogs.emc.com/stevewright/archive/2009/01/23/how-to-load-spatial-data-into-sql-server-2008-from-net.aspx which shows you can use ADO code like: 

    sqlCommand.Parameters.Add(new SqlParameter("@pCoOrdinates", geography) {UdtTypeName = "Geography"});

    However, in our scenario, the clients use SQLCE which does not support this UDT.

    When you wrote your prototype, did you try with Geography SQL type yet?

    Not yet. In our current prototype, we have 2 "standard" floating-point columns for Latitude and Longiture, which are not yet used. In terms of development timetables, the GPS data handling development is scheduled to begin in about a week from now. I just want to check this issue in advance, since we currently develop the sync infrastructure, and would like to minimize changes to it in the future.

    If you are using SqlSyncProvider and SqlCeSyncProvider for your scenario, you could consider creating DbSyncScopeDescription with Nvarchar for the Geography column, it will be understood by client side. You can reference this forum post for how to coding it: http://social.msdn.microsoft.com/Forums/en-US/syncdevdiscussions/thread/8f29a2f0-03c9-4609-b04b-574acf71f5a8

    Thanks for this example. I do use SqlSyncProvider and SqlCeSyncProvider in our scenario.

    I see, however, that the referenced answer is over a year old, and references a bug in SyncFX.

    Is this bug fixed in SyncFX 2.1 ?

    Is there a different code example for SyncFX 2.1 ?

    Do you have plans to support spatial fields, such as "Geography", in a more native way in the upcoming version of SyncFX ? After all, the "Geography" datatype is a .NET CLR type...


    Friday, May 6, 2011 4:59 AM
  • Hi,

    The bug in that post is for hub-spoke providers (SqlCeClientSyncProvider and DbServerSyncProvider), but not for the providers that you used.

    We don't have any other samples, and this code sample in the forum post should work for SyncFx 2.1 becaues we didn't change much in provisioning feature between SyncFx 2.0 and 2.1. We know what set of SQL types are not supported by SyncFx today, and we will consider how to support them in the future releases.

    Thanks,
    Dong


    This posting is provided AS IS with no warranties, and confers no rights.
    Friday, May 6, 2011 10:42 PM