开发者

How, WCF Ria Services can make a customised entity, known at client-side?

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>
  </Enti开发者_StackOverflow中文版tySet>

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!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜