/// <summary>
        /// Publish user info
        /// </summary>
        /// <param name="friend">friend obj</param>
        /// <returns>true if success</returns>
        public static bool PublishLocation(Friend friend)
        {
            using (MyFriendsModelContainer ctx = new MyFriendsModelContainer())
            {
                Friend locateFriend = ctx.Friends.SingleOrDefault(f => f.Id == friend.Id);
                if (locateFriend == null)
                {
                    ctx.Friends.AddObject(friend);
                    ctx.ObjectStateManager.ChangeObjectState(friend, System.Data.EntityState.Added);
                }
                else
                { 
                    //update
                    locateFriend.FriendName = friend.FriendName;
                    locateFriend.FriendImageUrl = friend.FriendImageUrl;
                    locateFriend.LastUpdated = friend.LastUpdated;
                    locateFriend.LocationStr = string.Format("POINT({0} {1})", friend.Latitude, friend.Longitude);

                    ctx.ObjectStateManager.ChangeObjectState(locateFriend, System.Data.EntityState.Modified);
                }
                bool success = ctx.SaveChanges() > 0;
                if (success)
                {
                    //update geography field
                    ctx.ExecuteFunction("UpdateFriendLocationById", new ObjectParameter[]
                                {
                                    new ObjectParameter("FriendID", friend.Id), 
                                });
                }
                return success;
            }
        }
 public static List<Friend> GetFriends(int skip, int take)
 {
     using (MyFriendsModelContainer ctx = new MyFriendsModelContainer())
     {
         ctx.ContextOptions.ProxyCreationEnabled = false;
         List<Friend> list = ctx.Friends.OrderByDescending(f=> f.LastUpdated).Skip(skip).Take(take).ToList();
         list.ForEach((f) =>
                          {
                              SqlGeometry geom = SqlGeometry.Parse(f.LocationStr);
                              f.Latitude = geom.STX.Value;
                              f.Longitude = geom.STY.Value;
                          });
         return list;
     }
 }