0

我构建了我的实体模型。我的一个业务对象,我们称它为 Store 具有空间数据类型。很快我发现空间字段不是通过 EF4 映射的。但是,我通过编辑定义如下查询的 xml 声明来努力摆脱困境:

  <EntitySet Name="Stores" EntityType="Eltrun.OnShelfAuditModel.Store.Stores">
    <DefiningQuery>
      SELECT [rowId], [storeName], [location].STAsText() as location FROM Stores
    </DefiningQuery>
  </EntitySet>

此时我决定通过像这样的部分类自定义我的 Store 实体,只是为了进行转换并仍然存储 SQLGeography 数据,在客户端只返回一个 double[](因为我既不能返回 SqlGeography,也不能返回 Location(Bing数据类型)。

public partial class Store
{
    public double[] StoreLocation
    {
        get
        {
            SqlGeography geoLocation = SqlGeography.
                 STPointFromText(new SqlChars(this.location.ToCharArray()), 4326);
            return new double[]{
                           (double)geoLocation.Lat, 
                           (double)geoLocation.Long};                
        }
    }

}

如何在客户端项目中了解我的小定制的存储数据类型?谢谢!

4

1 回答 1

1

Just add a setter to your property, and the RIA Services code generator and serializer should create the equivalent property on the client's version of the Store class.

Hope that helps...

于 2010-02-02T07:25:51.373 回答