views:

191

answers:

1

I constructed my Entity Model. One of my business objects,let's call it Store has a spatial data type. Very quickly I figured out that spatial fields aren't mapped via EF4. However I struggled my way out, by editing the xml declarations defining a query like the following:

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

At this point I decided to customize my Store entity via a partial class like this, just to make the conversion and still keep the SQLGeography data stored, returning just a double[] at client (as I cannot return neither SqlGeography, neither Location (Bing datatype).

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};                
        }
    }

}

How can I make aware the Store data type of my little customization, at client project? Thank you!

+1  A: 

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...

NikhilK