如何使用SQL CLR表值函数进行扩展
2007-12-27 15:30:25 来源:WEB开发网核心提示:在 FillRow 方法中,我使用呈现服务将每个 Route 对象转换成了地图图像,如何使用SQL CLR表值函数进行扩展(10),然后使用这一图像和该实体的位置数据填充行,public static void FillRow(Object obj, out SqlChars name, out SqlCharsadd
在 FillRow 方法中,我使用呈现服务将每个 Route 对象转换成了地图图像。然后使用这一图像和该实体的位置数据填充行。
public static void FillRow(Object obj, out SqlChars name, out SqlChars
address, out SqlBinary map)
{
Route route = (Route)obj;
// 构建地址字符串
Address endAddress =
route.Specification.Segments[1].
Waypoint.Location.Address;
string entityAddress = endAddress.AddressLine;
string enitityCity = endAddress.PrimaryCity;
string entityState = endAddress.Subdivision;
string entityName =
route.Specification.Segments[1].
Waypoint.Location.Entity.DisplayName;
// 对两列的值进行分配
name = new SqlChars(entityName);
address = new SqlChars(entityAddress + ' ' + enitityCity + ' ' +
entityState);
// 获取路线视图
ViewByHeightWidth view = route.Itinerary.View.ByHeightWidth;
RenderServiceSoap renderService = new RenderServiceSoap();
renderService.PreAuthenticate = true;
renderService.Credentials = new NetworkCredential(username, passwd);
// 显示带有路线的地图
MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = new MapView[]{view};
mapSpec.Route = route;
// 将地图指定给地图列
MapImage[] image = renderService.GetMap(mapSpec);
map = new SqlBinary(image[0].MimeData.Bits);
}
赞助商链接